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

问题描述:

我使用Exchange API从任何电子邮件地址发送约会请求。以下是我的代码:使用Exchange API自动在Outlook日历中创建条目

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("[email protected]"); 

appointment.Save(SendInvitationsMode.SendOnlyToAll); 

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

我想知道的是,是否可以直接输入与会者的Outlook日历,而不需要任何邀请电子邮件或与会者的任何批准?

+0

我试过了。它创建日历条目。但是,当我检查网络邮件时,我可以在日历中看到这个约会,但它不会在我的系统的Outlook(已安装的应用程序)中下载此约会。任何解决方法? –

+0

这听起来不对,我会重新检查您的逻辑,尝试禁用Outlook中的缓存模式,以查看是否也有所作为。它应该正确完成它应该工作。 –

+0

@SagarJoshi哪个教程你提到了2013版的交换?我的意思是你已经添加了“ExchangeService exService = new ExchangeService(ExchangeVersion.Exchange2013);”交换版本为2013年右侧,您使用了哪个库。即使我正在尝试,我只能使用,直到exchnage版本2010 SP2。你可以帮我吗? – coders

下面的代码可以帮助你。

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("[email protected]"); 
Meetings.add(appointment) 

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

欢迎使用*,除了提供代码之外,还请包含一些文字细节,解释你做了什么以及它为什么起作用。 – buczek