0 votes

i have checked the forum but i dont find answer
how to "mark mail as read"
i want to mark mails as read/ fwd/ or answered ?
so other ppl. ca see it in imap folder
please can you tell me the solution ?


1 Answer

0 votes
Best answer

You can find sample of mark emails as read using IMAP here:

using(Imap imap = new Imap())
    imap.Connect("imap.example.com");    // or ConnectSSL for SSL
    imap.UseBestLogin("user", "password");

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

Flag.Answered is defined defined as an "IMAP system flag" in RFC 2060:

client.FlagMessageByUID(uids[0], Flag.Answered);

Mail.dll supports all system flags - they are accessible through Flag
class static properties.

There is no standard flag for marking messages as forwarded. There exists "$Forwarded" flag defined in RFC 5788:

client.FlagMessageByUID(uids[0], new Flag(@"$Forwarded");


// in the latest version:
client.FlagMessageByUID(uids[0], Flag.Forwarded);  

Some IMAP servers may offer an additional (non RFC) flags for marking messages.
To be honest I don't know any IMAP server that does so.

You can also mark messages for internal purpose of your application, by using custom flags (also called Keywords) if your IMAP server supports it. (You simply create any new flag object using Flag constructor: new Flag("keyword").)

Note that the keywords are defined by you, so other applications accessing the same IMAP server will see those keywords, but won't understand their meaning.

by (298k points)
edited by