Question

I have used S22.imap library. And I have MailMessage with embedded images, links, etc. If I use WebBrowser and displayed MailMessage body, web browser component shows only text. I read many information and many people say, just save all linkedSource in local drive and build html file. Is there any other way? Much better approach.

using (ImapClient Client = new ImapClient(imapSettings.Imap_server, imapSettings.Port, imapSettings.Email, imapSettings.Password,AuthMethod.Login, true))
      {
          IEnumerable<uint> uids = Client.Search(SearchCondition.Unseen());
          IEnumerable<MailMessage> messages = Client.GetMessages(uids);
          LoadNewMessagesToDataBase(messages);
      }

List<MailMessage> messageList= messages.ToList();

webbrowser.DocumentText = messageList[i].body;
Was it helpful?

Solution

I found easy way:

var dataStream = messageList[i].AlternateViews[0].ContentStream;
byte[] byteBuffer = new byte[dataStream.Length];
string altbody =  System.Text.Encoding.UTF8.GetString(byteBuffer, 0, dataStream.Read(byteBuffer, 0, byteBuffer.Length));
webbrowser.DocumentText = altbody;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top