分类:
C#
public static void Outlook(string Subject, string TextBody, string FromAdd, string FromPass, string To, string CC, List<string> attach)
{
try
{
System.Diagnostics.Process[] MyProcess = System.Diagnostics.Process.GetProcessesByName("outlook");
if (MyProcess.Length == 0)
{
throw new System.Exception("请先启动OutLook!");
}
}
catch (System.Exception)
{
throw;
}
Microsoft.Office.Interop.Outlook.Application app = null;
NameSpace ns = null;
Microsoft.Office.Interop.Outlook._MailItem message = null;
try
{
app = new Microsoft.Office.Interop.Outlook.Application();
ns = app.GetNamespace("mapi");
ns.Logon(FromAdd, FromPass, false, true);
message = (Microsoft.Office.Interop.Outlook._MailItem)app.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
message.BodyFormat = Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatHTML;
message.To = To;
message.CC = CC;
message.Subject = Subject;
message.HTMLBody = TextBody;
if (attach != null)
{
foreach (string att in attach)
{
message.Attachments.Add(att);
}
}
message.Send();
ns.Logoff();
}
catch
{
throw;
}
finally
{
message = null;
ns = null;
app = null;
}
}
}
}评价
排名
6
文章
6
粉丝
16
评论
8
{{item.articleTitle}}
{{item.blogName}} : {{item.content}}
ICP备案 :渝ICP备18016597号-1
网站信息:2018-2025TNBLOG.NET
技术交流:群号656732739
联系我们:contact@tnblog.net
公网安备:
50010702506256
50010702506256
欢迎加群交流技术