Перетворення документа в MHTML і Надіслати Електронна пошта
Contents
[
Hide
]
Aspose.Words може конвертувати будь-який документ у формат MHTML (Web Archive). Це дозволяє зручно використовувати Aspose.Words і Aspose.Email
разом. Ви можете завантажити попередньо визначений документ у будь-якому форматі підтримки, такі як DOC, OOXML, або RTF, у Aspose.Words, заповнювати його даними, зберегти отриманий документ як MHTML, а потім відправити його електронною поштою за допомогою електронної пошти за допомогою Aspose.Email
й
Наприклад, наступний код показує, як перетворити будь-який документ на MHTML і відправити його електронною поштою:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET | |
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); |