Convert a Document to MHTML and Send It by Email

Contents
[ ]

Aspose.Words can convert any document to the MHTML (Web Archive) format. This makes it convenient to use Aspose.Words and Aspose.Email together. You can load a predefined document in any supported format, such as DOC, OOXML, or RTF, into Aspose.Words, fill it with data, save the resulting document as MHTML, and then send it by e-mail using Aspose.Email.

The following code example shows how to convert any document to MHTML and send it by email:


FAQ

  1. Q: Which document formats can be converted to MHTML with Aspose.Words?
    A: Aspose.Words supports conversion from all formats it can load, including DOC, DOCX, RTF, HTML, ODT, and many others. Any of these can be saved directly as MHTML.

  2. Q: Do I need a separate license for Aspose.Email when sending the MHTML file?
    A: Yes. Aspose.Words handles the conversion, while Aspose.Email is a separate product used for SMTP operations. Both products require their own valid licenses.

  3. Q: Is it possible to convert a document to MHTML without loading the entire file into memory?
    A: Yes. You can open the source document from a stream (Document doc = new Document(stream)) and save it directly to a stream in MHTML format, which reduces memory usage for large files.

  4. Q: How can I ensure the generated MHTML preserves the original document’s fonts and images?
    A: Aspose.Words embeds referenced resources (fonts, images, CSS) into the MHTML file automatically. Ensure the source document has access to the required resources, or embed them manually using Document.FontSettings before saving.