我有以下代码,可以从文件夹中读取一堆电子邮件。它使电子邮件很好,因为我可以看到电子邮件数量是正确的,标题也是正确的。 但是,它不会为身体返回任何内容。 我确实有一封带有简单文本的电子邮件,但它也不会返回任何内容。部分代码如下。 任何帮助不胜感激。我正在阅读的帐户来自Office 365,我使用了IMAP。连接 (*我可以从Microsoft Outlook中阅读这些电子邮件,所以我认为问题出在我的chilkat代码上(
Chilkat.MessageSet messageSet = imap.Search(@"ALL", fetchUids);
if (imap.LastMethodSuccess == false)
{
txtOutput.Text = txtOutput.Text + Environment.NewLine + imap.LastErrorText;
return;
}
// Fetch the email headers into a bundle object:
Chilkat.EmailBundle bundle = imap.FetchHeaders(messageSet);
if (imap.LastMethodSuccess == false)
{
txtOutput.Text = txtOutput.Text + Environment.NewLine + imap.LastErrorText;
return;
}
// Sort the email bundle by date, recipient, sender, or subject:
bool ascending = true ; bool descending = true;
bundle.SortByDate(ascending);
//bundle.SortByDate(descending);
// To sort by recipient, sender, or subject, call
// SortBySender, SortByRecipient, or SortBySubject.
// Display the Subject and From of each email.
int i = 0;
string body="";
while (i < bundle.MessageCount)
{
Chilkat.Email email = null;
email = bundle.GetEmail(i);
txtOutput.Text = txtOutput.Text + Environment.NewLine + Environment.NewLine + email.GetHeaderField("Date");
//Debug.WriteLine(email.GetHeaderField("Date"));
//Debug.WriteLine(email.Subject);
txtOutput.Text = txtOutput.Text + Environment.NewLine + email.From;
//Debug.WriteLine(email.From);
//Debug.WriteLine("--");
if (email.HasHtmlBody())
{
body = email.GetHtmlBody() + String.Empty;
}
else if (email.HasPlainTextBody())
{
body = email.GetPlainTextBody() + String.Empty;
}
else
{
body = email.Body + String.Empty;
}
txtOutput.Text = txtOutput.Text + Environment.NewLine + body.Trim() ;
i = i + 1;
}
您仅下载了标头:
Chilkat.EmailBundle bundle = imap.FetchHeaders(messageSet);
当然没有身体...