原創|其它|編輯:郝浩|2012-11-27 09:54:57.000|閱讀 2623 次
概述:Aspose.Words可以將任何文檔保存為MHTML(Web Archive)格式。這意味著如果同時使用Aspose.Words和Aspose.Network,生成和發送含有豐富內容的郵件將會變得很容易。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
Aspose.Words可以將任何文檔保存為MHTML(Web Archive)格式。這意味著如果同時使用Aspose.Words和Aspose.Network,生成和發送含有豐富內容的郵件將會變得很容易。例如,可以將一個預先定義的 DOC,OOXML或RTF文檔載入到Aspose.Words中,填入數據,保存為MHTML,然后使用Aspose.Network發送郵件。
C#
// Load the document into Aspose.Words. string srcFileName = Path.Combine(dataDir, "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 it. stream.Position = 0; // Create an Aspose.Network MIME email message from the stream. MailMessage message = MailMessage.Load(stream, MessageFormat.Mht); 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);
VB
' Load the document into Aspose.Words. Dim srcFileName As String = Path.Combine(dataDir, "DinnerInvitationDemo.doc") Dim doc As 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 it. stream.Position = 0 ' Create an Aspose.Network MIME email message from the stream. Dim message As MailMessage = MailMessage.Load(stream, MessageFormat.Mht) 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 New SmtpClient() client.Host = "your_smtp.com" client.AuthenticationMethod = SmtpAuthentication.None client.Send(message)
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自:慧都控件網