2015-07-13 146 views
1

我使用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日曆,而不需要任何邀請電子郵件或與會者的任何批准?

回答

1
+0

我試過了。它創建日曆條目。但是,當我檢查網絡郵件時,我可以在日曆中看到這個約會,但它不會在我的系統的Outlook(已安裝的應用程序)中下載此約會。任何解決方法? –

+0

這聽起來不對,我會重新檢查您的邏輯,嘗試禁用Outlook中的緩存模式,以查看是否也有所作爲。它應該正確完成它應該工作。 –

+0

@SagarJoshi哪個教程你提到了2013版的交換?我的意思是你已經添加了「ExchangeService exService = new ExchangeService(ExchangeVersion.Exchange2013);」交換版本爲2013年右側,您使用了哪個庫。即使我正在嘗試,我只能使用,直到exchnage版本2010 SP2。你可以幫我嗎? – coders

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

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

歡迎使用StackOverflow,除了提供代碼之外,還請包含一些文字細節,解釋你做了什麼以及它爲什麼起作用。 – buczek

相關問題