使用IMAP和MailSystem.NET通过消息ID查找电子邮件

问题描述 投票:1回答:2

我正在使用IMAP和MailSystem.NET来读取c#中的电子邮件。如何按邮件ID搜索电子邮件? (msg.MessageId)

 using (Imap4Client imap = new Imap4Client()){
        imap.ConnectSsl(protocol, port);
        imap.LoginFast(email, password);

        Mailbox inbox = imap.SelectMailbox("INBOX");

        int[] mails= inbox.Search("UNSEEN");

        for (int i = 0; i < mailsUnread.Length; i++) {
            Message msg = inbox.Fetch.MessageObject(mailsUnread[i]);
            string subject = msg.Subject;
           string body = msg.BodyText.Text;

           string messageId= msg.MessageId; 

         }
 }

谢谢

c# imap mailsystem.net
2个回答
1
投票

我强烈建议使用MailKit代替,因为它是比MailSystem.NET强得多的IMAP客户端库...但是...

基于MailSystem.NET中的Message-Id标头搜索消息的方式是:

int[] mails = inbox.Search (string.Format ("HEADER \"MESSAGE-ID\" \"{0}\"", msg.MessageId));

希望有所帮助。


0
投票
Parser.ParseMessage(inbox.Fetch.Message(messageId))
© www.soinside.com 2019 - 2024. All rights reserved.