using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Office.Interop.Outlook;
/**/////////////////////
/**//* 调用Outlook api 发起会议
/* mcjeremy@cnblogs.com
////////////////////
namespace OutlookAPI
{
class Program
{
static void Main(string[] args)
{
try
{
ApplicationClass oApp = new Microsoft.Office.Interop.Outlook.ApplicationClass();
//会议是约会的一种
AppointmentItem oItem = (AppointmentItem)oApp.CreateItem(OlItemType.olAppointmentItem);
oItem.MeetingStatus = OlMeetingStatus.olMeeting;
oItem.Subject = "主题";
oItem.Body = "内容";
oItem.Location = "地点";
//开始时间
oItem.Start = DateTime.Now.AddDays(1);
//结束时间
oItem.End = DateTime.Now.AddDays(2);
//提醒设置
oItem.ReminderSet = true;
oItem.ReminderMinutesBeforeStart = 5;
//是否全天事件
oItem.AllDayEvent = false;
oItem.BusyStatus = OlBusyStatus.olBusy;
//索引从1开始,而不是从0
//发件人的帐号信息
oItem.SendUsingAccount = oApp.Session.Accounts[2];
//添加必选人
Recipient force = oItem.Recipients.Add("mailuser2@mailserver.com");
force.Type = (int)OlMeetingRecipientType.olRequired;
//添加可选人
Recipient opt = oItem.Recipients.Add("mailuser3@p.mailserver.com");
opt.Type = (int)OlMeetingRecipientType.olOptional;
//添加会议发起者
Recipient sender = oItem.Recipients.Add("mailuser1@mailserver.com");
sender.Type = (int)OlMeetingRecipientType.olOrganizer;
oItem.Recipients.ResolveAll();
//oItem.SaveAs("d:/TEST.MSG", OlSaveAsType.olMSG);
oItem.Send();
//MailItem mItem = (MailItem)oApp.CreateItem(OlItemType.olMailItem);
//Recipient rTo = mItem.Recipients.Add("****");
//rTo.Type = (int)OlMailRecipientType.olTo;
//Recipient rCC=mItem.Recipients.Add("****");
//rCC.Type = (int)OlMailRecipientType.olCC;
//Recipient rBC = mItem.Recipients.Add("****");
//rBC.Type = (int)OlMailRecipientType.olBCC;
Console.WriteLine("OK");
}
catch (System.Exception ex)
{
Console.WriteLine(ex.Message);
}
Console.ReadLine();
}
}
}