This project is read-only.

Convert to MHTML Email

Aspose.Words can save any document in MHTML (Web Archive) format. This makes it very easy to use Aspose.Words and Aspose.Email together to generate and send email messages with rich content. For example, you can load a predefined DOC, OOXML or RTF document into Aspose.Words, fill it with data, save as MHTML and then email using Aspose.Email.

            // Load the document into Aspose.Words.
            string srcFileName = Path.Combine("Converting Document.docx");
            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.Email can read it.
            stream.Position = 0;

            // Create an Aspose.Network MIME email message from the stream.
            MailMessage message = MailMessage.Load(stream, MessageFormat.Mht);
            message.From = "";
            message.To = "";
            message.Subject = "Aspose.Words + Aspose.Email MHTML Test Message";

            // Send the message using Aspose.Email
            SmtpClient client = new SmtpClient();
            client.Host = "";
            client.Port = 587;
            client.EnableSsl = true;
            client.AuthenticationMethod = SmtpAuthentication.Auto;


Last edited Mar 3, 2014 at 6:13 AM by asposemarketplace, version 3