This project is read-only.

How to see the body of the mail?

Jul 28, 2009 at 4:46 PM
hello,

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 6: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 9:56 AM

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

Jul 30, 2009 at 6:31 AM
Edited Jul 30, 2009 at 6: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());
connection.Open();
authenticate.Login();
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);
authenticate.Logout();
connection.Close();

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.