使用Exchange API在Outlook日历中自动创建条目

时间:2015-07-13 07:13:04

标签: calendar exchange-server outlook-calendar

我正在使用Exchange API从任何电子邮件地址发送约会请求。以下是我的代码:

ExchangeService exService = new ExchangeService(ExchangeVersion.Exchange2013);
exService.Url = new Uri("exchange URL");
exService.Credentials = new WebCredentials("userID", "password");

Appointment appointment = new Appointment(exService);

appointment.Subject = "Test Subject";
appointment.Body = "test body";
appointment.Location = "Location";
appointment.Start = <Meeting start time>;
appointment.End = <Meeting end time>
appointment.RequiredAttendees.Add("abc@xyz.com");

appointment.Save(SendInvitationsMode.SendOnlyToAll);

此代码工作正常:它会向与会者发送邀请电子邮件。

我想知道的是,是否可以直接登录参与者的Outlook日历,而无需任何邀请电子邮件或参与者的任何批准?

2 个答案:

答案 0 :(得分:1)

答案 1 :(得分:0)

以下代码可能会对您有所帮助。

ExchangeService exService = new ExchangeService(ExchangeVersion.Exchange2013);
exService.Url = new Uri("exchange URL");
exService.Credentials = new WebCredentials("userID", "password");

Collection<Appointment> Meetings = new Collection<Appointment>();

Appointment appointment = new Appointment(exService);

appointment.Subject = "Test Subject";
appointment.Body = "test body";
appointment.Location = "Location";
appointment.Start = <Meeting start time>;
appointment.End = <Meeting end time>
appointment.RequiredAttendees.Add("abc@xyz.com");
Meetings.add(appointment)

ServiceResponseCollection<ServiceResponse> responses = service.CreateItems(Meetings,WellKnownFolderName.Calendar,MessageDisposition.SendOnly,SendInvitationsMode.SendToNone);