Skip to content

Instantly share code, notes, and snippets.

@aspose-words-gists
Created July 9, 2024 18:38
Aspose.Words for .NET. Convert file to MHTML using C#.
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET.git.
Document doc = new Document(MyDir + "Document.docx");
Stream stream = new MemoryStream();
doc.Save(stream, SaveFormat.Mhtml);
// Rewind the stream to the beginning so Aspose.Email can read it.
stream.Position = 0;
// Create an Aspose.Email MIME email message from the stream.
MailMessage message = MailMessage.Load(stream, new MhtmlLoadOptions());
message.From = "your_from@email.com";
message.To = "your_to@email.com";
message.Subject = "Aspose.Words + Aspose.Email MHTML Test Message";
// Send the message using Aspose.Email.
SmtpClient client = new SmtpClient();
client.Host = "your_smtp.com";
client.Send(message);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment