2014-03-06 48 views
1

我正在使用EWS託管API。我剛開始擺弄擴展屬性。所以我寫了簡單的代碼發送附加了擴展屬性的簡單郵件。發送帶擴展屬性的郵件時發生內部服務器錯誤

形成郵件部分我簡單複製粘貼從this MSDN頁面。爲了測試目的,我壓制了證書驗證。

這是我的完整代碼:

1  ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; }; 
2  service = new ExchangeService(ExchangeVersion.Exchange2007_SP1); 
3  service.TraceListener = new TraceListener(); 
4  service.TraceEnabled = false; 
5 
6  service.Credentials = new WebCredentials("[email protected]", "[email protected]"); 
7  service.Url = new Uri("https://exchng.domain.com/EWS/Exchange.asmx"); 
8 
9  Guid MyPropertySetId = new Guid("{C11FF724-AA03-4555-9952-8FA248A11C3E}"); 
10 
11  // Create a definition for the extended property. 
12  ExtendedPropertyDefinition extendedPropertyDefinition = new ExtendedPropertyDefinition(MyPropertySetId, "Expiration Date", MapiPropertyType.String); 
13 
14  // Create an e-mail message that you will add the extended property to. 
15  EmailMessage message = new EmailMessage(service); 
16  message.Subject = "Saved with extendedPropertyDefinition of two days"; 
17  message.Body = "The expiration date is contained within the extended property."; 
18  message.ToRecipients.Add("[email protected]"); 
19 
20  // Add the extended property to an e-mail message object named "message". 
21  message.SetExtendedProperty(extendedPropertyDefinition, DateTime.Now.AddDays(2).ToString()); 
22 
23  // Save the e-mail message. 
24  message.SendAndSaveCopy(); 

我上線24獲得異常以下(不帶嵌套的內部異常):

An internal server error occurred. The operation failed. 
    at Microsoft.Exchange.WebServices.Data.ServiceResponse.InternalThrowIfNecessary() 
    at Microsoft.Exchange.WebServices.Data.ServiceResponse.ThrowIfNecessary() 
    at Microsoft.Exchange.WebServices.Data.MultiResponseServiceRequest`1.Execute() 
    at Microsoft.Exchange.WebServices.Data.ExchangeService.InternalCreateItems(IEnumerable`1 items, FolderId parentFolderId, Nullable`1 messageDisposition, Nullable`1 sendInvitationsMode, ServiceErrorHandling errorHandling) 
    at Microsoft.Exchange.WebServices.Data.ExchangeService.CreateItem(Item item, FolderId parentFolderId, Nullable`1 messageDisposition, Nullable`1 sendInvitationsMode) 
    at Microsoft.Exchange.WebServices.Data.Item.InternalCreate(FolderId parentFolderId, Nullable`1 messageDisposition, Nullable`1 sendInvitationsMode) 
    at Microsoft.Exchange.WebServices.Data.EmailMessage.InternalSend(FolderId parentFolderId, MessageDisposition messageDisposition) 
    at Microsoft.Exchange.WebServices.Data.EmailMessage.SendAndSaveCopy()  

如果我評論的行號21,代碼工作罰款併發送消息。那麼爲什麼它擴展屬性失敗?

回答

1

我試圖與Microsoft連接。他們給了我一個診斷工具,它捕獲了Exchange Server的內部日誌,並將其上傳到Microsoft服務器,然後由Microsoft團隊進行分析。在Exchange Server日誌中,我們意識到有MapiExceptionNamedPropsQuotaExceeded,這是在默認配額增加了什麼交換供應時發生的。

精確異常情況如下:

Mapping 'An internal server error occurred. 
The operation failed.' used for exception   
'Microsoft.Exchange.Data.Storage.StoragePermanentException: 
Cannot get ID from name. ---> Microsoft.Mapi.MapiExceptionNamedPropsQuotaExceeded: 
MapiExceptionNamedPropsQuotaExceeded: Unable to get IDs from property names. 
(hr=0x80040900, ec=-2147219200) 

作爲最後的解決辦法,我通過修改註冊表的Windows在HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MSExchangeIS\<Server Name>\<Database Type-GUID>與名Named Props Quota添加DWORD和其值設置爲十進制16K增加了命名屬性的配額。這解決了這個問題。

詳細步驟可以參考here

有關命名屬性的更多信息可在here找到。

相關問題