How to see the body of the mail?

Jul 28, 2009 at 3:46 PM

I apologize in advance for my English.

I can retrieve the list of mails, but I can not find the code to display the body of the mail.

Should we view it in a WebBrowser?

Thank you in advance for your help.
Jul 28, 2009 at 5:21 PM

I got a few things to work using the IMAP.Test project.  From what I can see the project was never completed.   The parts that are complete are brilliant though.


Jul 29, 2009 at 8:56 AM

So it's not currently possible to view the body of the message?

Jul 30, 2009 at 5:31 AM
Edited Jul 30, 2009 at 5:32 AM

Below is some code that should work on the current version:


ImapConnect connection = new ImapConnect(ConfigurationManager.AppSettings["ImapServer"]);
ImapCommand command = new ImapCommand(connection);
ImapAuthenticate authenticate = new ImapAuthenticate(connection, Session["Username"].ToString(), Session["Password"].ToString());
ImapMailbox mailbox = command.Select("INBOX");
command.SetSeen(id, true);
ImapMailboxMessage message = command.FetchBodyStructure(command.FetchHeaders(id));
if (message.HasHTML)
   message = command.FetchBodyPart(message, message.HTML);
else if (message.HasText)
   message = command.FetchBodyPart(message, message.Text);

This should populate the message object with the message body.

Anyway been taking a bit of a break, but I am starting to think a single method that retrieves all message parts might be useful.