2015-10-31 29 views
0

我正在使用EWS來管理Exchange Server電子郵件帳戶的操作。如何導出.ics文件中的所有約會日曆? 我已經嘗試遵循。如何使用EWS將.ics文件中的所有約會導出?

string iCalFileName = Path.Combine(Path.GetTempPath(), "appointments.ics"); 
foreach (Appointment appointment in service.FindItems(WellKnownFolderName.Calendar, new ItemView(int.MaxValue))) 
{ 
    appointment.Load(); 
    using (FileStream fs = new FileStream(iCalFileName, FileMode.Create, FileAccess.Write)) 
    { 
     using (StreamWriter s = new StreamWriter(fs)) 
     { 
      s.WriteLine(appointment.MimeContent.Content);//error must load property before using it 
     } 
    } 
} 

有人能告訴我我在這裏失蹤了嗎?

回答

0

當您使用FindItem時,不會返回MimeContent(和一些其他屬性),您需要對每個項目進行單獨的GetItem調用以檢索該項目。做最好的辦法是使用LoadPropertiesFromItems這將一批管理API的請求的GetItem看到http://blogs.msdn.com/b/exchangedev/archive/2010/03/16/loading-properties-for-multiple-items-with-one-call-to-exchange-web-services.aspx

乾杯 格倫

+0

我要導出所有預約ics文件相同,如Gmail。我已經嘗試過,但我沒有獲得成功。我曾嘗試通過https://msdn.microsoft.com/en-us/library/office/dn672317(v=exchg.150).aspx。我也試過你的解決方案。你能建議我鏈接或例子,這有助於我導出所有的約會/會議在ics文件? –

+0

我建議你先發布日曆http://blogs.technet.com/b/exchange/archive/2014/04/15/how-to-publish-anonymous-calendar-sharing-url-in-exchange-online -or-exchange-2013.aspx,那麼你可以得到像Imail一樣的Ical Feed。 –

相關問題