2012-07-10 96 views
1

我面臨使用EWS託管API發送帶邀請附件的問題。約會與會者未收到任何添加到約會的附件,但 附件確實出現在創建約會的人的日曆中。EWS - 附件未發送邀請

這裏是我的代碼片段:

try 
{ 
    ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP1, TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time")); 
    service.Credentials = new WebCredentials("calendar_user", "password1", "acme"); 
    service.Url = new Uri("https://acme.com/EWS/Exchange.asmx"); 

    Appointment appointment = new Appointment(service); 
    service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, "[email protected]"); 

    String UID = "D09F3FF6-1461-414C-89E8-C05BC3B66A4A"; 
    appointment.ICalUid = UID; 
    appointment.Subject = "Test Subject"; 
    appointment.Body = "Test Content."; 
    appointment.Start = new DateTime(2012, 07, 11, 17, 00, 0); 
    appointment.End = appointment.Start.AddMinutes(30); 

    FileAttachment attachment = appointment.Attachments.AddFileAttachment(@"C:\Users\tintin\Documents\Test.xlsx"); 
    attachment.IsInline = false; 

    appointment.RequiredAttendees.Add("[email protected]"); 

    appointment.Save(SendInvitationsMode.SendToAllAndSaveCopy); 
} 
catch (Exception ex) 
{ 

} 

回答

2

樣子EWS與附件處理可怕的限制。我找到了一種解決方法來解決這個需要更新約會對象兩次的問題。

appointment.ICalUid = UID; 
appointment.Subject = "Test Subject"; 
appointment.Body = "Test Content."; 
appointment.Start = new DateTime(2012, 07, 11, 17, 00, 0); 
appointment.End = appointment.Start.AddMinutes(30); 

FileAttachment attachment = appointment.Attachments.AddFileAttachment(@"C:\Users\tintin\Documents\Test.xlsx"); 
attachment.IsInline = false; 

appointment.Save(folderCalendar, SendInvitationsMode.SendToNone); 
appointment.RequiredAttendees.Add("[email protected]"); 

appointment.Update(ConflictResolutionMode.AutoResolve, SendInvitationsOrCancellationsMode.SendToAllAndSaveCopy); 
0

看起來像這個問題是特定於Exchange Server 2010服務包1.我有類似的問題,當我更改版本到SP2問題得到解決。下面的代碼解決了這個問題

ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2); 
0

第二次更新沒有訣竅,但它會導致在底部取消會議。不能在產品中使用它。 它無法將版本更改爲SP2。

仍然找到更好的解決方案。

相關問題