+1 vote

I just ordered your mail library which I am very happy with.

I have a use case where I need to read message from an imap server without marking them as read.

I read this blog post:
https://www.limilabs.com/blog/peek-message-on-imap-server

I states that: "There are Peek methods for downloading headers and even parts of the email message."

How big a part of the message will be downloaded? Is it possible to download the full message using PeekMessageByUID?

by

1 Answer

0 votes
 
Best answer

PeekMessageByUID downloads entire email message, including all attachments (exactly the same set of data as GetMessageByUID method).

using(Imap imap = new Imap())
{
    imap.ConnectSSL("imap.example.com");
    imap.UseBestLogin("user", "password");

    imap.SelectInbox();
    List<long> uidList = imap.Search(Flag.Unseen);

    foreach (long uid in uidList)
    {
        IMail email = new MailBuilder()
            .CreateFromEml(imap.PeekMessageByUID(uid));

        string subject = email.Subject;
    }
    imap.Close();
}

There are other Peek methods that allow getting only parts of email message, or headers only.

by (297k points)
...