[英]Imap Mail : AE.NET.Mail Body Of Emails Are Empty
我使用AE.NET.Mail讀取電子郵件正文。
但是這些屍體都是空的!
我的代碼如下:
// Connect to the IMAP server. The 'true' parameter specifies to use SSL
// which is important (for Gmail at least)
ImapClient ic = new ImapClient("imap.soscharge.com", "main@domain.tk", "123",
ImapClient.AuthMethods.Login, 143, false);
// Select a mailbox. Case-insensitive
ic.SelectMailbox("INBOX");
Console.WriteLine(ic.GetMessageCount());
// Get the first *11* messages. 0 is the first message;
// and it also includes the 10th message, which is really the eleventh ;)
// MailMessage represents, well, a message in your mailbox
MailMessage[] mm = ic.GetMessages(0, 10);
foreach (MailMessage m in mm)
{
Response.Write(m.Sender + "<br /><br />");
}
foreach (MailMessage m in mm)
{
Response.Write(m.Sender + "<br /><br />");
}
// Probably wiser to use a using statement
ic.Dispose();
我的電子郵件是utf-8編碼的。
有什么問題,我該如何抓住那些屍體?
提前致謝
GetMessages()方法中有一個用於“ headersonly”的默認參數,默認情況下為true,當指定為false時,將下載消息的正文:
using (ImapClient ic = new ImapClient("imap.gmail.com",
"anemail@example.org",
"PasswordGoesHere!",
ImapClient.AuthMethods.Login,
993, true))
{
ic.SelectMailbox("INBOX");
Console.WriteLine(ic.ListMailboxes("",""));
// Note that you must specify that headersonly = false
// when using GetMesssages().
MailMessage[] mm = ic.GetMessages(0, 10, false);
foreach (MailMessage m in mm)
{
Console.WriteLine(m.From);
Console.WriteLine(m.Body);
Console.WriteLine();
}
}
Console.ReadKey();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.