Author |
|
hamipers Newbie
Joined: 06 March 2008 Location: United States
Online Status: Offline Posts: 11
|
Posted: 07 May 2008 at 11:35am | IP Logged
|
|
|
I retrieve email messages in a specific folder such as inbox by using Imap.DownloadEntireMessages method. I display them in a GridView in an ASP.NET web page and I would like to let the user distinguish between read and unread mail messages by changing the color of GridView rows according to read status of the messages. But when I looked into MailMessage class, I didn't find any property indicating that. How would I know that if a specific message has been read or not?
|
Back to Top |
|
|
Andrew AfterLogic Support
Joined: 28 April 2006 Location: United States
Online Status: Offline Posts: 1189
|
Posted: 08 May 2008 at 6:15am | IP Logged
|
|
|
To distinguish between read and unread messages, you should use Envelope.Flags property. SystemMessageFlags.Seen flag set means message is read, unset means unread.
To access message flags, you should download messages via Imap.DownloadEnvelopes method. Message data will be available in Envelope.MessagePreview property if you specify EnvelopeParts.MessagePreview in parts parameter of DownloadEnvelopes method.
However, you shouldn't download entire messages (EnvelopeParts.MessagePreview) to build message list, just envelopes with headers is enough, otherwise, it'll generate too much network traffic. Once a user clicks a message, your application should download the entire message to show its contents.
Also, once a message gets entirely downloaded from IMAP server (with EnvelopeParts.MessagePreview and bodyPreviewSize = -1), it's automatically marked as read. Downloading envelopes without EnvelopeParts.MessagePreview doesn't affect read/unread flag.
Best regards,
Andrew
|
Back to Top |
|
|