2015-07-21 27 views
0

我需要編寫Outlook應用程序,我需要將一些信息添加到擴展屬性中。我在我的JS代碼中使用Office.context.mailbox.item.saveAsync()將消息保存到草稿文件夾中。 然後我通過item.saveAsync()回調生成EWS XML請求,以獲得Id保存草稿的ChangeKey。 而現在我想通過下面的XML請求添加擴展屬性:使用EWS XML請求將擴展屬性添加到保存在草稿文件夾中的郵件中

<?xml version="1.0" encoding="utf-8"?> 
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"  xmlns:t=http://schemas.microsoft.com/exchange/services/2006/types  xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
    <soap:Header> 
     <t:RequestServerVersion Version="Exchange2007_SP1" /> 
     <t:TimeZoneContext> 
      <t:TimeZoneDefinition Id="Eastern Standard Time" /> 
     </t:TimeZoneContext> 
    </soap:Header> 
    <soap:Body> 
     <m:UpdateItem MessageDisposition="SaveOnly" ConflictResolution="AutoResolve"> 
      <m:ItemChanges> 
       <t:ItemChange> 
        <t:ItemId Id="AQMkAGYzMmY5ZjQ1LTZiZDAtNGUwMy1hN2I0LThmNWM3NGYyY2VhMABGAAADVxv6DmzCb0aSDWQq9af2cwcAiSvs3uFZHUqIGSh2GUm6AAADAQ8AAACJK+ze4VkdSogZKHYZSboAAAI7ViIAAAA=" ChangeKey="CQAAABYAAACJK+ze4VkdSogZKHYZSboAAAAAO3qD" /> 
        <t:Updates> 
         <t:SetItemField> 
          <t:ExtendedFieldURI PropertySetId="c11ff724-aa03-4555-9952-8fa248a11c3e" PropertyName="prop1" PropertyType="String" /> 
          <t:Message> 
           <t:ExtendedProperty> 
            <t:ExtendedFieldURI PropertySetId="c11ff724-aa03-4555-9952-8fa248a11c3e" PropertyName="prop1" PropertyType="String" /> 
            <t:Value>prop1Value</t:Value> 
           </t:ExtendedProperty> 
          </t:Message> 
         </t:SetItemField> 
         <t:SetItemField> 
          <t:ExtendedFieldURI PropertySetId="c11ff724-aa03-4555-9952-8fa248a11c4e" PropertyName="prop2" PropertyType="String" /> 
          <t:Message> 
           <t:ExtendedProperty> 
            <t:ExtendedFieldURI PropertySetId="c11ff724-aa03-4555-9952-8fa248a11c4e" PropertyName="prop2" PropertyType="String" /> 
            <t:Value>prop2Value</t:Value> 
           </t:ExtendedProperty> 
          </t:Message> 
         </t:SetItemField> 
         <t:SetItemField> 
          <t:ExtendedFieldURI PropertySetId="c11ff724-aa03-4555-9952-8fa248a11c5e" PropertyName="prop3" PropertyType="String" /> 
          <t:Message> 
           <t:ExtendedProperty> 
            <t:ExtendedFieldURI PropertySetId="c11ff724-aa03-4555-9952-8fa248a11c5e" PropertyName="prop3" PropertyType="String" /> 
            <t:Value>prop3Value</t:Value> 
           </t:ExtendedProperty> 
          </t:Message> 
         </t:SetItemField> 
         <t:SetItemField> 
          <t:ExtendedFieldURI PropertySetId="c11ff724-aa03-4555-9952-8fa248a11c6e" PropertyName="prop4" PropertyType="String" /> 
          <t:Message> 
           <t:ExtendedProperty> 
            <t:ExtendedFieldURI PropertySetId="c11ff724-aa03-4555-9952-8fa248a11c6e" PropertyName="prop4" PropertyType="String" /> 
            <t:Value>prop4Value</t:Value> 
           </t:ExtendedProperty> 
          </t:Message> 
         </t:SetItemField> 
        </t:Updates> 
       </t:ItemChange> 
      </m:ItemChanges> 
     </m:UpdateItem> 
    </soap:Body> 
</soap:Envelope> 

但在回調我收到失敗的狀態,但此錯誤

The remote server returned an error: (400) Bad Request.

我用https://msdn.microsoft.com/en-us/library/office/dd633633%28v=exchg.80%29.aspx作爲樣本。

我需要通過單擊「發送」按鈕發送帶有擴展屬性的消息。

我該怎麼做?

回答

1

這可能是您的編碼字符串。

"utf-8"的雙引號中交換Web服務扼流圈。

用途:Content-Type: text/xml; charset=utf-8

相關問題