我使用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日历,而不需要任何邀请电子邮件或与会者的任何批准?
不能,但是如果您冒充与会者,您可以代表他们接受邀请。看到:
- https://msdn.microsoft.com/en-us/library/office/dd633680 (v = exchg.80) . aspx
- https://msdn.microsoft.com/en-us/library/office/dd633648 (v = exchg.80) . aspx
下面的代码可能对您有所帮助。
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);