+1 vote

When I use:

List<long> uids = client.Search(Flag.Unseen);

hiewver, it marks the emails as read.
I need to obtain the IDs without marking them as read.

I'm using Mail.dll version 3.0.


1 Answer

0 votes
Best answer

IMAP SEARCH shouldn't change the seen/unseen status of an email.

Are you absolutely sure that your server does that?

Most likely it's the subsequent Imap.GetMessage call that does that.

Use Imap.PeekMessage instead of Imap.GetMessage in order to prevent that:

using(Imap client = new Imap())
    client.UseBestLogin("user", "password/app password"); 
    // client.LoginOAUTH2(user, accessToken)


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

    foreach (long uid in uidList)
        IMail email = new MailBuilder()

        string subject = email.Subject;
by (298k points)