Free Support Forum - aspose.com

Display Word document in Outlook message

I need to convert a word document to display in an outlook message.

So far I load the document and save it as Mhtml.

Dim doc As New Aspose.Words.Document(“C:\tests.doc”)
Dim stream As New MemoryStream()
doc.Save(stream, Aspose.Words.SaveFormat.Mhtml)
stream.Position = 0


Then create a new Mail.MailMessage using the converted word document:

Dim msg As Aspose.Network.Mail.MailMessage = Aspose.Network.Mail.MailMessage.Load(stream)


Then I create an Outlook message using the MailMessage and save it:

Dim outlookMsg As Outlook.MapiMessage = Outlook.MapiMessage.FromMailMessage(msg)

MailFileLocation = Current.Server.MapPath(String.Format("~/Download/Letter/Mail/{0}.msg", DateTime.Now.Ticks.ToString(“x”)))
outlookMsg.Save(MailFileLocation)


Then output the file to the browser which is the picked up by MS Outlook:

'Get the file info
Dim file As System.IO.FileInfo = New System.IO.FileInfo(MailFileLocation)

'write to browser
Current.Response.Clear()
Current.Response.AddHeader(“Content-Disposition”, “attachment; filename=” & file.Name)
Current.Response.AddHeader(“Content-Length”, file.Length.ToString())
Current.Response.ContentType = “application/octet-stream”
Current.Response.WriteFile(file.FullName)
Current.Response.End()


Is there anything I am missing or an extra step I am doing that isn’t necessary? The outlook message displays all text as 12pt Times New Roman.


Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. Could you please attach your original and output document here for testing? I will check the issue on my side and provide you more information.

Best regards,

The document and .msg file are in the zipped attachment.


Many thanks.

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. I tried converting your document to MHTML and output document looks correct. Font of text is Arial 10. Can you confirm that MHTML produced on your side is also correct? If so, the problem occurs somewhere in your code or in Aspose.Network.

I used the latest version of Aspose.Words for testing. You can download it from here:

http://www.aspose.com/community/files/51/.net-components/aspose.words-for-.net/category1188.aspx

Best regards,

If I send the email it appears correctly, but when creating an Outlook.MapiMessage it doesn’t.


Dim message As Aspose.Network.Mail.MailMessage = Aspose.Network.Mail.MailMessage.Load(stream)

message.From = "jamie@xxx.co.uk"

message.To = "jamie@xxxco.uk"

message.Subject = “Aspose.Words + Aspose.Network MHTML Test Message”

’ Send the message using Aspose.Network

Dim client As New Aspose.Network.Mail.SmtpClient

client.Host = “xenda10”

client.Send(message)

I guess this suggests the the document is being converted to Mhtml correctly, however the format is upset when we call:

Dim outlookMsg As Outlook.MapiMessage = Outlook.MapiMessage.FromMailMessage(msg)

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. I will move your request in Aspose.Network forum. My colleagues will answer you shortly.

Best regards,

Hi,

While loading the email body from an mhtml document using MailMessage.Load() method, it preserves the formatting if you either save it as .eml format or send to an email address. However, there is an issue while saving as msg format using MailMessage.Save() method.

We are looking into this issue. I have logged it in our bug tracking system (ID: 13472). We will notify you as soon as we make some progress to fix this. We are sorry for the inconvenience.

The issues you have found earlier (filed as 13472) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(1)