C#ActiveUp Mail无法获取消息

时间:2014-09-15 07:39:52

标签: c# imap gmail-imap

我正在尝试循环使用ActiveUp Mail C#的特定收件箱中的所有邮件:

Mailbox box = imap.AllMailboxes[0];
Fetch fetch = box.Fetch;
int messagesLeft = box.MessageCount; // return 31
int msgIndex = 0;

List<Email> list = new List<Email>();
for (int x = 1; x <= box.MessageCount; x++)
{
    try
    {
        Message msg = fetch.MessageObject(x);
        list.Add(new Email()
        { 
            /// .....
        }); 
    }
    catch { }
}

我收到所有邮件的错误(1除外)..

  

索引和长度必须指代字符串中的位置。

所有消息(除了效果良好的1)都来自同一个发件人且格式相同(内容不同)

1 个答案:

答案 0 :(得分:0)

Imap4Client client = new Imap4Client();
client.Connect("server", 143);
client.Login("***", "***");
foreach (var box in client.AllMailboxes.OfType<Mailbox>())
{
  for (int i = 1; i <= box.MessageCount; i++)
  {
     // a u wish
     Header heade = box.Fetch.MessageObject(i);
  }
}
相关问题