Hello Aspose,
We wrote an Outlook Add-in that will allow people save emails into our System.
When the user chooses to save an email into our system we present a dialog to the user in which they will see a “Preview” of the email. This normally works just fine, but recently we’ve been seeing emails for which this process takes a very long time.
As luck would have it, this would be happening for emails internal to our company, like “messages from our CEO” and the likes. So I was able to obtain a sample of such an email without any sensitive data, and I will attach it to this topic.
In order to obtain the “Preview” PDF we need to use two of your products. Aspose.Email and Aspose.Words. We would use Aspose.Email to create a HTML stream to represent the email and then Aspose.Words to convert that to PDF.
These are the steps we execute (in VB code) up to the point where the long delay occurs:
Dim oEml As Aspose.Email.MailMessage = Nothing
Dim oSaveOptions As Aspose.Email.HtmlSaveOptions = Nothing
Dim oStream As IO.MemoryStream = Nothing
Dim oWords As Aspose.Words.Document = Nothing
Dim oWordsOptions As Aspose.Words.Loading.LoadOptions = Nothing
oEml = Aspose.Email.MailMessage.Load(sFile)
oEml.TimeZoneOffset = TimeZone.CurrentTimeZone.GetUtcOffset(oEml.Date.ToLocalTime)
oSaveOptions = New Aspose.Email.HtmlSaveOptions
oSaveOptions.HtmlFormatOptions = Aspose.Email.HtmlFormatOptions.WriteCompleteEmailAddress Or Aspose.Email.HtmlFormatOptions.WriteHeader Or Aspose.Email.HtmlFormatOptions.DisplayAsOutlook
oSaveOptions.MailMessageSaveType = Aspose.Email.MailMessageSaveType.HtmlFormat
oStream = New IO.MemoryStream
oEml.Save(stream:=oStream, options:=oSaveOptions)
oWordsOptions = New Aspose.Words.Loading.LoadOptions
oWordsOptions.LoadFormat = Aspose.Words.LoadFormat.Html
oWords = New Aspose.Words.Document(oStream, oWordsOptions)
It’s that last statement that causes a LONG delay.
Email template test.zip (315.9 KB)
See the attached file for a sample .msg file that causes this problem.
By the way, after loading the HTML into Aspose.Words we simply save it as a PDF
oWords.Save(fileName:=sToFileName, saveFormat:=Aspose.Words.SaveFormat.Pdf)
It would be great if you could find out why these emails in particular are taking so long to process with the above code and fix it. Alternatively, if you can suggest a better way to produce an identical looking PDF from a .msg file, we’d be happy to change our code.