0

我想转换Microsoft.Office.Interop.Outlook.MailItemStream. 我怎样才能做到这一点?下面的代码显示了我如何构建 Outlook MailItem。

Microsoft.Office.Interop.Outlook.Application outlookApp =
    new Microsoft.Office.Interop.Outlook.Application();

Microsoft.Office.Interop.Outlook.MailItem mailItem = 
    (Microsoft.Office.Interop.Outlook.MailItem)outlookApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);

Microsoft.Office.Interop.Outlook.NameSpace mapiNameSpace = 
    outlookApp.GetNamespace("MAPI");

mailItem.Subject = .....
mailItem.To = ....

就像我将数据分配给 Outlook MailItem。如何将此 MailItem 转换为流?

4

1 回答 1

0

创建一个System.Net.Mail.MailMessage对象,从中复制属性 Outlook.MailItem并保存。

var msg = new System.Net.Mail.MailMessage();
msg.From = new System.Net.Mail.MailAddress("aaa@bb.com");
msg.To.Add("cccc@ddd.net");
msg.Subject = "test test";

var client = new System.Net.Mail.SmtpClient();
client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.SpecifiedPickupDirectory;
client.PickupDirectoryLocation = @"c:\temp";
client.Send(msg);
于 2012-08-28T09:34:53.593 回答