彩票走势图

如何使用Aspose.Words将文件转换为MHTML和Email

原创|其它|编辑:郝浩|2012-11-27 09:54:57.000|阅读 2583 次

概述: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@pclwef.cn

文章转载自:慧都控件网

为你推荐

  • 推荐视频
  • 推荐活动
  • 推荐产品
  • 推荐文章
  • 慧都慧问
扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP