Hi, I’m using the Aspose.Email class to convert incoming emails to a SharePoint document library to MSG format and for some reason the body of themails are being converted to pain text (ugly signatures).
The SharePoint event supplies a stream for the incoming email that I read into an EML file (MailMessage) then generate an MSG file using the EML and save the MSG out to a file in the library.
My problem is that emails sent to the library from external accounts, like Gmail, survive the conversion process while email sent from (Outlook) accounts on the same domain as the SharePoint server have their HTML bodies converted to plain text.
Here is the code I’m using:
public override void EmailReceived(SPList list, SPEmailMessage emailMessage, String receiverData)
{
MemoryStream MSGmemoryStream;
MemoryStream MSGstream;
Stream RawStream = emailMessage.GetMessageStream();
MailMessage EMLMessage = MailMessage.Load(RawStream, MessageFormat.Eml);
EMLMessage.Save(MSGmemoryStream, MailMessageSaveType.OutlookMessageFormatUnicode);
MapiMessage MSGMessage = MapiMessage.FromStream(MSGmemoryStream);
MSGMessage.Save(MSGstream);
SPFile fl = list.RootFolder.Files.Add(destinationList.RootFolder.ServerRelativeUrl + "/" + filename, MSGstream, true);
SPListItem NewEmailItem = fl.Item;
}
I don't know why this code works fine for some emails and not for others. I can't find any way of distiguishing between an email sent from gmail / hotmail / yahoo and one sent from and Outlook client. As this is the only difference I am assuming it has something to do with the program that sends the email in the first place.
Thanks, Peter.