0 votes

Hi,

I have an application that reads all my unseen mail and sends it across for processing.At the end of processing, it will mark those emails as marked using MarkMessageSeenByUID() method.When i try to get my unseen emails again using imap.Search(Flag.Unseen) statement, it returns me the list of unseen emails which includes mails that are marked as read as well.Please provide me solution for this ASAP.

Regards
V Balaji.Ch

by (200 points)
How does your code look like? How does the log look like:
https://www.limilabs.com/blog/logging-in-mail-dll
Hi,

Thanks for responding.

Here is my code snippet:

using (Imap imap = new Imap())
{

 imap.Connect(ConfigurationManager.AppSettings["imapHost"], Convert.ToInt32(ConfigurationManager.AppSettings["imapPort"]));

                 
 imap.UseBestLogin(ConfigurationManager.AppSettings["userMail"], ConfigurationManager.AppSettings["password"]);
                        
 imap.SelectInbox();

List<long> uids = imap.Search(Flag.Unseen);
List<MessageInfo> infos = imap.GetMessageInfoByUID(uids);

foreach (MessageInfo info in infos)
{
   IMail email = new MailBuilder().CreateFromEml(imap.GetMessageByUID(info.UID.Value));

   //Do some processing

   imap.MarkMessageSeenByUID(info.UID.Value);

}
  imap.Close();
}

1 Answer

0 votes

Your code looks more or less correct. If the server is not marking the messages correctly there is not much you can do.

What I can advise is to look at the logs, and having those report this error to server manufacturer. Please also make sure that no other user is marking those messages as unseen.

As a side note: GetMessageByUID automatically marks email messages as seen. There is no need to use MarkMessageSeenByUID.

You can use PeekMessageByUID if you don't want to set \SEEN flag on the email you are downloading.

by (301k points)
...