Is it possible to only download message once

I see that I can use imap.SelectFolder.count to get the number of messages.
Then use

For number As Integer = 1 To imap.SelectFolder.count
       Dim message As MailMessage = imap.GetMessage(number)
Next

to get the message.

The message number doesn’t represent a specific message so do I have to download the entire message over and over as I am checking the inbox for new messages? Or is there a way to know the unique message id before doing the imap.GetMessage() so that I only download a message once?

Thanks,
Shawn

Hi Shawn,

Instead of using ImapClient.GetMessage(int messageNumber), you should try using ImapClient.GetMessage(string uid).

For example:

Dim infos As IList(Of ImapMessageInfo) = imap.ListMessages()

For Each info As ImapMessageInfo In infos
    Dim message As MailMessage = imap.GetMessage(info.Uid)
Next

Then you would be able to keep track of UID values that you have processed.

Does this solve your issue?

Regards,
Mario