我想将Microsoft.Office.Interop.Outlook.MailItem
转换为Stream
。我怎样才能做到这一点?下面的代码显示了我如何构建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转换为流?
答案 0 :(得分: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);