[The information in this article applies to Aspose.Words for .NET only.]
Starting with Aspose.Words for .NET 5.2 it is now possible to save any document in MHTML (Web Archive) format. It makes it very easy to use Aspose.Words and Aspose.Network together to generate email messages with rich content and send them. You can load a predefined DOC, OOXML, RTF or HTML document into Aspose.Words, fill it with data, save as MHTML and then email using Aspose.Network.
Example SaveMhtmlAndEmail
Shows how to save any document from Aspose.Words as MHTML and email using Aspose.Network.
[C#]
// Load the document into Aspose.Words.
string srcFileName = Path.Combine(docsDir, "DinnerInvitationDemo.doc");
Document doc = new Document(srcFileName);
// Save into a memory stream in MHTML format.
Stream stream = new MemoryStream();
doc.Save(stream, SaveFormat.Mhtml);
// Rewind the stream to the beginning so Aspose.Network can read.
stream.Position = 0;
// Create an Aspose.Network MIME email message from the stream.
MailMessage message = MailMessage.Load(stream);
message.From = "your_from@email.com";
message.To = "your_to@email.com";
message.Subject = "Aspose.Words + Aspose.Network MHTML Test Message";
// Send the message using Aspose.Network
SmtpClient client = new SmtpClient();
client.Host = "your_smtp.com";
client.AuthenticationMethod = SmtpAuthentication.None;
client.Send(message);
[Visual Basic]
' Load the document into Aspose.Words.
Dim srcFileName As String = Path.Combine(docsDir, "DinnerInvitationDemo.doc")
Dim doc As Document = New Document(srcFileName)
' Save into a memory stream in MHTML format.
Dim stream As Stream = New MemoryStream()
doc.Save(stream, SaveFormat.Mhtml)
' Rewind the stream to the beginning so Aspose.Network can read.
stream.Position = 0
' Create an Aspose.Network MIME email message from the stream.
Dim message As MailMessage = MailMessage.Load(stream)
message.From = "your_from@email.com"
message.To = "your_to@email.com"
message.Subject = "Aspose.Words + Aspose.Network MHTML Test Message"
' Send the message using Aspose.Network
Dim client As SmtpClient = New SmtpClient()
client.Host = "your_smtp.com"
client.AuthenticationMethod = SmtpAuthentication.None
client.Send(message)