How to Mark the Mail as Read in IMAP Protocol

May 17, 2014 at 9:00 AM
Edited May 17, 2014 at 9:00 AM
Hi All,

I am just going through the documentation & yeah I have found how to mark email as UNREAD & for that below is the code

cl.ExecuteStore(1, StoreItem.FlagsReplace, "UNSEEN") ===> This is working & setting email as UNREAD

But how to mark email as Read... I am not sure about that I have tried using the below thing but it didn't worked out :(

cl.ExecuteStore(1, StoreItem.FlagsReplace, "READ") ==> This is not working

cl.ExecuteStore(1, StoreItem.FlagsReplace, "SEEN") ==> This is not working

So any 1 please tell me solution for the same. ?
May 18, 2014 at 7:40 AM
I am still waiting for the reply... on this... so any 1 please suggest me..
Coordinator
May 19, 2014 at 12:50 PM
Hi.
Try it.
this.ExecuteStore(1, StoreItem.FlagsRemove, "\\Seen")
Marked as answer by rickjackson on 6/3/2014 at 6:41 AM
Aug 6, 2014 at 11:52 AM
Edited Aug 6, 2014 at 11:54 AM
Hi higty ..

my question is same as rickjackson
cl.ExecuteStore(1, StoreItem.FlagsRemove, "\\Seen")
not working for me. It is not setting my mail status as read(seen).
cl.ExecuteStore(1, StoreItem.FlagsReplace, "READ") ==> This is not working

cl.ExecuteStore(1, StoreItem.FlagsReplace, "SEEN") ==> This is not working
And what is this in
this.ExecuteStore(1, StoreItem.FlagsRemove, "\\Seen")
Coordinator
Aug 6, 2014 at 11:55 PM
Hi.

What mail server do you use?
You can get all flags by calling GetMessageFlags method of ImapClient object with latest version.
Could you tell me what flags is set to your message by calling this method?
It may help to solve this problem.

regards.
Aug 7, 2014 at 4:16 AM
Edited Aug 7, 2014 at 5:02 AM
I am using gmail service. Here is my total code(some people are telling it will set the email status as read by default but it is not setting for me)
 Using cl As New ImapClient("imap.gmail.com")
            With cl
                cl.Port = 993
                cl.Ssl = True
                cl.UserName = "naresh.236236@gmail.com"
                cl.Password = "*********"

                If cl.Authenticate() = True Then

                    Dim folder As ImapFolder = cl.SelectFolder("INBOX")
           
                    Dim list As SearchResult = cl.ExecuteSearch("UNSEEN")

                    For i As Integer = 0 To list.MailIndexList.Count - 1
                        Dim mg As Object = cl.GetMessage(list.MailIndexList(i))
                      
          'cl.ExecuteStore(list.MailIndexList(i), StoreItem.FlagsRemove, "UNSEEN")
          'cl.ExecuteStore(list.MailIndexList(i), StoreItem.FlagsReplace, "UNSEEN")

           cl.ExecuteStore(list.MailIndexList(i), StoreItem.FlagsRemove, "\\Seen")

           'cl.ExecuteStore(list.MailIndexList(i), StoreItem.FlagsReplace, "READ")
           'cl.ExecuteStore(list.MailIndexList(i), StoreItem.FlagsReplace, "SEEN")

                    Next
             
                    'Next

                End If

            End With
        End Using
I have tried all commented lines to set as read. still it is not setting as read. When I read a mail from my application I want it to be marked as read(seen).
cl.ExecuteStore(list.MailIndexList(i), StoreItem.FlagsReplace, "UNSEEN")
this line is able to mark the seen email as unread(unseen).
Coordinator
Aug 7, 2014 at 7:38 AM
Hi.

Thank you for your replay.
I'll investigate this problem with your information.

sincerely.
Oct 14, 2014 at 12:05 PM
Edited Oct 14, 2014 at 12:51 PM
Hi higty,

POP3 -> cl.ExecuteQuit();

IMAP -> cl.ExecuteClose();

mark as read for email.
Coordinator
Oct 20, 2014 at 11:21 PM
Hi askatesi.

Thank you for your post.
I'll check it.

regards.