c# 调用OutLook
第一部分:发送邮件
public static void OutlookToEmail() { Application App = new Application(); MailItem Item = (MailItem)App.CreateItem(OlItemType.olMailItem); Item.To = "xxxx@qq.com"; Item.Subject = "xxx需求会议"; Item.BodyFormat = OlBodyFormat.olFormatHTML; string content = "啦啦啦德玛西亚!"; Item.HTMLBody = content; ((_MailItem)Item).Send(); Item = null; App = null; }
第二部分:发送会议邀请
public static void OutlookToMeetingInvitation() { string[] Requireds = { "xxxxx@qq.com" };//收件人 string[] Optionals = { "xx@galaxysoftware.com.cn" };//抄送人 try { ApplicationClass App = new ApplicationClass(); //会议是约会的一种 AppointmentItem Item = (AppointmentItem)App.CreateItem(OlItemType.olAppointmentItem); Item.MeetingStatus = OlMeetingStatus.olMeeting; //邮件主题 Item.Subject = "xxx需求会议"; //邮件内容 Item.Body = "啦啦啦德玛西亚!"; //地址 Item.Location = "东方明珠塔"; //开始时间 Item.Start = Convert.ToDateTime("2018-12-18 17:30"); //结束时间 Item.End = Convert.ToDateTime("2018-12-18 18:30"); //提醒设置 Item.ReminderSet = true; Item.ReminderMinutesBeforeStart = 10; //提前多长时间通知 //是否全天事件 Item.AllDayEvent = false; Item.BusyStatus = OlBusyStatus.olBusy; //索引从1开始,而不是从0 //发件人的帐号信息 Item.SendUsingAccount = App.Session.Accounts[1]; Recipient force = null; for (int i = 0; i < Requireds.Count(); i++) { if (!string.IsNullOrWhiteSpace(Requireds[i])) { //收件人 force = Item.Recipients.Add(Requireds[i]); } if (force != null) { force.Type = (int)OlMeetingRecipientType.olRequired; } } Recipient opt = null; for (int i = 0; i < Optionals.Count(); i++) { if (!string.IsNullOrWhiteSpace(Optionals[i])) { //抄送人 opt = Item.Recipients.Add(Optionals[i]); } if (opt != null) { opt.Type = (int)OlMeetingRecipientType.olOptional; } } Item.Recipients.ResolveAll(); ((_AppointmentItem)Item).Send(); //System.Threading.Thread.Sleep(3000); } catch (System.Exception e) { } }

浙公网安备 33010602011771号