Hi,
I am using trying to display the content of an email in a browser window and am trying to get as close as possible to the layout (e.g. fonts, spacing etc) that shows in Outlook 2007.
I am using the code below, which extracts the html body but the source is quite different to that rendered by Outlook in the Reading Pane. Do you have any suggestions as to how I might get closer to the reading pane layout or ideally exactly the same? Or if it is possible to create a reading pane object, pass the msg stream to it and get back the resulting HTML.
Thanks.
Aaron.
Aspose.Network.Mail.MailMessage mm;
mm = Aspose.Network.Mail.MailMessage.Load(fileStream, Aspose.Network.Mail.MessageFormat.Msg);
if (mm.HtmlBody.ToString() != “”)
{
PreviewText = mm.HtmlBody.ToString();
}
Hi Aaron,
Thanks for considering Aspose.
Aspose.Network has some known issues in getting embedded images and some HTML formatting problems when you get HTML text from body of the email message.
Could you please post a sample msg file, that will help us further to resolve the issue.
Hi,
i have the same problem. i posted some msg files.
regards
Thomas
Cool, thanks Thomas, the more the merrier!
I've attached a sample too, which contains the original msg and the html source from both the preview pane in outlook and the Aspose HTMLBody property.
If you need anything else please let me know!
Thanks,
Aaron.
Hi,
The Html formatting issues were fixed in Aspose.Network for .NET 5.1. Please try the latest release from http://www.aspose.com/community/files/51/.net-components/aspose.network-for-.net/default.aspx
Hi,
I tried to update my code to use 5.1 but I am getting the following exception. Searching on the forums suggest an issue with obfuscation tool you use. Can you please confirm if this works properly or if there is something else I should look at?
The code is running in the context of SharePoint 2010, which is running in a .Net 2.0 application pool. I have tried both the 64bit and 32bit versions of Aspose.Network to no avail.
This is the line that fails:
mm = Aspose.Network.Mail.MailMessage.Load(fileStream, Aspose.Network.Mail.MessageFormat.Msg);
The details of the exception are as follows:
System.TypeInitializationException: The type initializer for 'Aspose.Network.Outlook.x53d96b48aa328901' threw an exception. ---> System.TypeInitializationException: The type initializer for 'Aspose.Network.Outlook.MapiPropertyTag' threw an exception. ---> System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at Aspose.Network.Outlook.MapiPropertyTag..cctor()
--- End of inner exception stack trace ---
at Aspose.Network.Outlook.x53d96b48aa328901..ctor()
at Aspose.Network.Outlook.x53d96b48aa328901..cctor()
--- End of inner exception stack trace ---
at Aspose.Network.Outlook.x53d96b48aa328901.xc03b5d42009bec3a()
at Aspose.Network.Outlook.MapiMessageReader.ReadMessage()
at Aspose.Network.Mail.MailMessage.Load(Stream stream, MessageFormat format)
at MacroView.DMF.MessageService2007.<>c__DisplayClass18e.b__18b()
at Microsoft.SharePoint.SPSecurity.<>c__DisplayClass4.b__2()
at Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode)
Thanks,
Aaron.
Further to the information above this is NOT an issue for 4.9.0.0 or eariler, it seems to have started in 5.0.0.0 because 5.0 and 5.1 exhibit the same symptoms.
Hi Aaron,
Hi,
I have just tested this on 5.8.0.0 of Aspose.Network and the issue still exists. Have you been able to verify the results in SharePoint?
Thanks.
Aaron.
Hi Aaron,
Thanks for that. I will try using the 64-bit version.
My issue is that I have one version of my code that can run on 32-bit or 64-bit so that I can cope with SharePoint 2007 and 2010. The weird thing is that 5.1 didn't work, 5.2 did (which is what I have now) and 5.8 does not. Before I go re-architecting my solution, I'd like to be 100% sure that this is not something that should just work, or got broken in a recent build and might be fixed in the future.
Thanks,
Aaron.