Using A Microsoft Word Document As The Message Body And ...
Maybe your like
- Using Microsoft Word Documents as Email Body
This article shows you how to use a Microsoft Word document as the email body and send it to recipients. The sample document is a sales invoice from the Northwind database sample, exported to Microsoft Word format. Aspose.Email for .NET deals with network protocols and Microsoft Outlook features and cannot handle Microsoft Word documents. To overcome this, the samples in this article use Aspose.Words for .NET to load the Word document and convert it to MHTML format. Aspose.Email for .NET uses the MHTML document in the email body.
Using Microsoft Word Documents as Email Body
The programming samples below illustrate how to send a Word document as an email body using Aspose.Words for .NET and Aspose.Email for .NET:
- Load a Microsoft Word document using Aspose.Word for .NET’s Document class.
- Save it in MHTML format.
- Load the MHTML document using Aspose.Email for .NET’s MailMessage class to set the email body.
- Set other message properties using different MailMessage class properties and methods.
- Send the email using Aspose.Email for .NET’s SMTPClient class.
The source document, a sales invoice exported to Microsoft Word from the Microsoft Northwind sample can be seen below.

When the message has been sent and received in Microsoft Outlook, it looks like the message below.

The HTML formatting and images are preserved as in the original source document when viewed in either Outlook or a web email client like Gmail or Hotmail. Below is a screenshot of the message when opened with Gmail in a Chrome browser.

The following code snippet shows you how to use a Microsoft Word document as the message body and send an email by using SmtpClient class instance.
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-.NET // Load a Word document from disk and save it to stream as MHTML Document wordDocument = new Document(folderPath + "invoice.docx"); MemoryStream mhtmlStream = new MemoryStream(); wordDocument.Save(mhtmlStream, SaveFormat.Mhtml); // Load the MHTML in a MailMessage object mhtmlStream.Position = 0; using (MailMessage message = MailMessage.Load(mhtmlStream, new MhtmlLoadOptions())) { message.Subject = "Sending Invoice by Email"; message.From = "[email protected]"; message.To = "[email protected]"; // Save the message in MSG format to disk message.Save(folderPath + "WordDocAsEmailBody_out.msg", SaveOptions.DefaultMsgUnicode); // Send the email message using (SmtpClient client = new SmtpClient("smtp.gmail.com", 587, "[email protected]", "password")) { client.SecurityOptions = SecurityOptions.SSLExplicit; client.Send(message); } }Tag » How To Email Word Document
-
Email A Document From Microsoft Office
-
How To Send A Word Document As An Email Attachment In Word 2016
-
Sending Documents By Email | Microsoft WORD For Beginners
-
How To Send Word Documents Through Email - Techwalla
-
Send Word Document As Email Body
-
8 Ways To Send A Word Document - WikiHow
-
How To Send A Document Via Email In Word 2016
-
Emailing Documents In Microsoft Word - Office Articles
-
Email Documents Using Word 2010 - Tutorialspoint
-
How To Link To A File, Email, Or Location In A Word Document
-
In Order To Email A Word Document From Within MS Word - Toppr
-
How Do I Email A Word Document Without Losing Formatting? - Quora
-
How To Save The Formatting When Emailing A Word Document
-
How To Export One Or Multiple Emails To Word Document In Outlook?