+1 vote

I need to connect, fetch unseen messages from Gmail (& i've done), but KEEP unseen the message so with my mobile client i can look at the gmail box e receive new messages unread. I don't want lose flag state of message. How i can do this with Mail object ? (IMAP reader)

by (550 points)

1 Answer

0 votes
 
Best answer

Use Imap.PeekMessageByUID instead of Imap.GetMessageByUID when you download the emails.

using(Imap imap = new Imap())
{
    imap.ConnectSSL("imap.server.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)); //<-- Peek

        string subject = email.Subject;
    }
    imap.Close();
}
by (301k points)
selected by
Thank You Very Much, it works !!
...