邮件保存在 Outlook 桌面版后,自定义 x 标头将被删除
我一直在开发一个 Outlook 加载项,该加载项根据与用户的交互插入自定义 x 标头。 Outlook Web 应用程序运行良好。当这些自定义 x 标头从 Outlook 桌面版(Windows 10 和 macOS Monterey 版本 12.2)的邮件中消失时,我遇到了问题。
环境信息:
Windows 10 Pro 版本为 21H2,操作系统版本 19044.1469
Microsoft Office Professional Plus 2019
Microsoft® Outlook® 2019 MSO(版本 2110 Build 16.0.14527.20234) 32 位
macOS Monterey 版本 12.2
Mac 版本 16.53 (21091200)
Microsoft Outlook for 确保标头插入成功,为了查明标头消失的时刻,我使用 Windows10 上的 OutlookSpy 工具手动执行加载项逻辑。结果是相同的,看起来标头已被保存消息操作删除。
详细信息如下:
打开撰写,输入主题,使用 ctrl+S 或按带有磁盘映像的按钮保存消息。在草稿文件夹中创建的消息
导航到草稿文件夹中的消息。打开 OutlookSpy EWS 请求板并发送以下 EWS GetItem 请求以查找 ChangeKey。当前项目 ID 在 EWS 请求板中提供
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<soap:Header>
<t:RequestServerVersion Version="Exchange2010"/>
</soap:Header>
<soap:Body>
<GetItem
xmlns="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<ItemShape>
<t:BaseShape>IdOnly</t:BaseShape>
</ItemShape>
<ItemIds>
<t:ItemId Id="AAMkAGQ2NjU3NGQ2LTFjMGItNGM1ZC1hMjMzLTM1YjUzYzYyZDY3NABGAAAAAABOqCUOqEzcRIky8XqnjNqxBwCNVxNVF2AuQZAWaNgbSGc1AAAAAAEPAACNVxNVF2AuQZAWaNgbSGc1AADrvkZMAAA="/>
</ItemIds>
</GetItem>
</soap:Body>
</soap:Envelope>
- 响应消息返回当前 ChangeKey
<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<h:ServerVersionInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" Version="V2018_01_08" MinorBuildNumber="15" MajorBuildNumber="5081" MinorVersion="20" MajorVersion="15"/>
</s:Header>
<s:Body>
<m:GetItemResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
<m:ResponseMessages>
<m:GetItemResponseMessage ResponseClass="Success">
<m:ResponseCode>NoError</m:ResponseCode>
<m:Items>
<t:Message>
<t:ItemId ChangeKey="CQAAABYAAACNVxNVF2AuQZAWaNgbSGc1AADrDEAU" Id="AAMkAGQ2NjU3NGQ2LTFjMGItNGM1ZC1hMjMzLTM1YjUzYzYyZDY3NABGAAAAAABOqCUOqEzcRIky8XqnjNqxBwCNVxNVF2AuQZAWaNgbSGc1AAAAAAEPAACNVxNVF2AuQZAWaNgbSGc1AADrvkZMAAA="/>
</t:Message>
</m:Items>
</m:GetItemResponseMessage>
</m:ResponseMessages>
</m:GetItemResponse>
</s:Body>
</s:Envelope>
- 发送以下 EWS UpdateItem 请求以设置自定义 x 标头。使用上一步中收到的 ChangeKey
<soap:Body>
<UpdateItem MessageDisposition="SaveOnly" ConflictResolution="AlwaysOverwrite"
xmlns="http://schemas.microsoft.com/exchange/services/2006/messages">
<ItemChanges>
<t:ItemChange>
<t:ItemId Id="AAMkAGQ2NjU3NGQ2LTFjMGItNGM1ZC1hMjMzLTM1YjUzYzYyZDY3NABGAAAAAABOqCUOqEzcRIky8XqnjNqxBwCNVxNVF2AuQZAWaNgbSGc1AAAAAAEPAACNVxNVF2AuQZAWaNgbSGc1AADrvkZMAAA="
ChangeKey="CQAAABYAAACNVxNVF2AuQZAWaNgbSGc1AADrDEAU"/>
<t:Updates>
<t:SetItemField>
<t:ExtendedFieldURI DistinguishedPropertySetId="InternetHeaders" PropertyName="x-custom-header1" PropertyType="String"/>
<t:Message>
<t:ExtendedProperty>
<t:ExtendedFieldURI DistinguishedPropertySetId="InternetHeaders" PropertyName="x-custom-header1" PropertyType="String"/>
<t:Value>yes</t:Value>
</t:ExtendedProperty>
</t:Message>
</t:SetItemField>
</t:Updates>
</t:ItemChange>
</ItemChanges>
</UpdateItem>
</soap:Body>
</soap:Envelope>
- 对 UpdateItem 请求的响应显示成功/无错误,冲突数为 0
<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<h:ServerVersionInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" Version="V2018_01_08" MinorBuildNumber="15" MajorBuildNumber="5081" MinorVersion="20" MajorVersion="15"/>
</s:Header>
<s:Body>
<m:UpdateItemResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
<m:ResponseMessages>
<m:UpdateItemResponseMessage ResponseClass="Success">
<m:ResponseCode>NoError</m:ResponseCode>
<m:Items>
<t:Message>
<t:ItemId ChangeKey="CQAAABYAAACNVxNVF2AuQZAWaNgbSGc1AADrDECs" Id="AAMkAGQ2NjU3NGQ2LTFjMGItNGM1ZC1hMjMzLTM1YjUzYzYyZDY3NABGAAAAAABOqCUOqEzcRIky8XqnjNqxBwCNVxNVF2AuQZAWaNgbSGc1AAAAAAEPAACNVxNVF2AuQZAWaNgbSGc1AADrvkZMAAA="/>
</t:Message>
</m:Items>
<m:ConflictResults>
<t:Count>0</t:Count>
</m:ConflictResults>
</m:UpdateItemResponseMessage>
</m:ResponseMessages>
</m:UpdateItemResponse>
</s:Body>
</s:Envelope>
- 发送以下 EWS GetItem 请求以检查是否已设置自定义 x 标头。使用上一步中收到的 ChangeKey
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<soap:Header>
<t:RequestServerVersion Version="Exchange2010"/>
</soap:Header>
<soap:Body>
<GetItem
xmlns="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<ItemShape>
<t:AdditionalProperties>
<t:FieldURI FieldURI="item:Subject" />
<t:ExtendedFieldURI DistinguishedPropertySetId="InternetHeaders" PropertyName="x-custom-header1" PropertyType="String" />
</t:AdditionalProperties>
</ItemShape>
<ItemIds>
<t:ItemId Id="AAMkAGQ2NjU3NGQ2LTFjMGItNGM1ZC1hMjMzLTM1YjUzYzYyZDY3NABGAAAAAABOqCUOqEzcRIky8XqnjNqxBwCNVxNVF2AuQZAWaNgbSGc1AAAAAAEPAACNVxNVF2AuQZAWaNgbSGc1AADrvkZMAAA="
ChangeKey="CQAAABYAAACNVxNVF2AuQZAWaNgbSGc1AADrDECs" />
</ItemIds>
</GetItem>
</soap:Body>
</soap:Envelope>
- GetItem 响应包含在步骤 3 中设置的自定义 x-header
<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<h:ServerVersionInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" Version="V2018_01_08" MinorBuildNumber="15" MajorBuildNumber="5081" MinorVersion="20" MajorVersion="15"/>
</s:Header>
<s:Body>
<m:GetItemResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
<m:ResponseMessages>
<m:GetItemResponseMessage ResponseClass="Success">
<m:ResponseCode>NoError</m:ResponseCode>
<m:Items>
<t:Message>
<t:ItemId ChangeKey="CQAAABYAAACNVxNVF2AuQZAWaNgbSGc1AADrDECs" Id="AAMkAGQ2NjU3NGQ2LTFjMGItNGM1ZC1hMjMzLTM1YjUzYzYyZDY3NABGAAAAAABOqCUOqEzcRIky8XqnjNqxBwCNVxNVF2AuQZAWaNgbSGc1AAAAAAEPAACNVxNVF2AuQZAWaNgbSGc1AADrvkZMAAA="/>
<t:Subject>test ews 3</t:Subject>
<t:ExtendedProperty>
<t:ExtendedFieldURI PropertyType="String" PropertyName="x-custom-header1" DistinguishedPropertySetId="InternetHeaders"/>
<t:Value>yes</t:Value>
</t:ExtendedProperty>
</t:Message>
</m:Items>
</m:GetItemResponseMessage>
</m:ResponseMessages>
</m:GetItemResponse>
</s:Body>
</s:Envelope>
在撰写窗口中,在消息正文中键入某些内容,然后使用 ctrl+S 或按 按钮保存消息磁盘映像
上一步中的保存操作将修改项目 ChangeKey。发送以下GetItem请求以获取新的ChangeKey
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<soap:Header>
<t:RequestServerVersion Version="Exchange2010"/>
</soap:Header>
<soap:Body>
<GetItem
xmlns="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<ItemShape>
<t:BaseShape>IdOnly</t:BaseShape>
</ItemShape>
<ItemIds>
<t:ItemId Id="AAMkAGQ2NjU3NGQ2LTFjMGItNGM1ZC1hMjMzLTM1YjUzYzYyZDY3NABGAAAAAABOqCUOqEzcRIky8XqnjNqxBwCNVxNVF2AuQZAWaNgbSGc1AAAAAAEPAACNVxNVF2AuQZAWaNgbSGc1AADrvkZMAAA=" />
</ItemIds>
</GetItem>
</soap:Body>
</soap:Envelope>
- 成功的响应将返回新的 ChangeKey
<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<h:ServerVersionInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" Version="V2018_01_08" MinorBuildNumber="15" MajorBuildNumber="5081" MinorVersion="20" MajorVersion="15"/>
</s:Header>
<s:Body>
<m:GetItemResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
<m:ResponseMessages>
<m:GetItemResponseMessage ResponseClass="Success">
<m:ResponseCode>NoError</m:ResponseCode>
<m:Items>
<t:Message>
<t:ItemId ChangeKey="CQAAABYAAACNVxNVF2AuQZAWaNgbSGc1AADrDEDV" Id="AAMkAGQ2NjU3NGQ2LTFjMGItNGM1ZC1hMjMzLTM1YjUzYzYyZDY3NABGAAAAAABOqCUOqEzcRIky8XqnjNqxBwCNVxNVF2AuQZAWaNgbSGc1AAAAAAEPAACNVxNVF2AuQZAWaNgbSGc1AADrvkZMAAA="/>
</t:Message>
</m:Items>
</m:GetItemResponseMessage>
</m:ResponseMessages>
</m:GetItemResponse>
</s:Body>
</s:Envelope>
- 发送以下 EWS GetItem 请求以检查自定义 x 标头是否仍然存在。使用上一步中收到的 ChangeKey
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<soap:Header>
<t:RequestServerVersion Version="Exchange2010"/>
</soap:Header>
<soap:Body>
<GetItem
xmlns="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<ItemShape>
<t:AdditionalProperties>
<t:FieldURI FieldURI="item:Subject" />
<t:ExtendedFieldURI DistinguishedPropertySetId="InternetHeaders" PropertyName="x-custom-header1" PropertyType="String" />
</t:AdditionalProperties>
</ItemShape>
<ItemIds>
<t:ItemId Id="AAMkAGQ2NjU3NGQ2LTFjMGItNGM1ZC1hMjMzLTM1YjUzYzYyZDY3NABGAAAAAABOqCUOqEzcRIky8XqnjNqxBwCNVxNVF2AuQZAWaNgbSGc1AAAAAAEPAACNVxNVF2AuQZAWaNgbSGc1AADrvkZMAAA="
ChangeKey="CQAAABYAAACNVxNVF2AuQZAWaNgbSGc1AADrDEDV" />
</ItemIds>
</GetItem>
</soap:Body>
</soap:Envelope>
- 收到的 GetItem 响应不包含我们的自定义 x-header
<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<h:ServerVersionInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" Version="V2018_01_08" MinorBuildNumber="15" MajorBuildNumber="5081" MinorVersion="20" MajorVersion="15"/>
</s:Header>
<s:Body>
<m:GetItemResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
<m:ResponseMessages>
<m:GetItemResponseMessage ResponseClass="Success">
<m:ResponseCode>NoError</m:ResponseCode>
<m:Items>
<t:Message>
<t:ItemId ChangeKey="CQAAABYAAACNVxNVF2AuQZAWaNgbSGc1AADrDEDV" Id="AAMkAGQ2NjU3NGQ2LTFjMGItNGM1ZC1hMjMzLTM1YjUzYzYyZDY3NABGAAAAAABOqCUOqEzcRIky8XqnjNqxBwCNVxNVF2AuQZAWaNgbSGc1AAAAAAEPAACNVxNVF2AuQZAWaNgbSGc1AADrvkZMAAA="/>
<t:Subject>test ews 3</t:Subject>
</t:Message>
</m:Items>
</m:GetItemResponseMessage>
</m:ResponseMessages>
</m:GetItemResponse>
</s:Body>
</s:Envelope>
I've been working on an Outlook add-in which inserts custom x-headers based on interaction with a user. Outlook Web Application works fine. I encountered a problem when these custom x-headers disappeared from the message in Outlook Desktop (Windows 10 and macOS Monterey version 12.2).
The environment info:
Windows 10 Pro version is 21H2, OS build 19044.1469
Microsoft Office Professional Plus 2019
Microsoft® Outlook® 2019 MSO (Version 2110 Build 16.0.14527.20234) 32-bit
macOS Monterey version 12.2
Microsoft Outlook for Mac Version 16.53 (21091200)
To make sure that the insertion of the headers was successful and to pinpoint the moment when the headers disappear I performed the Add-in logic manually by using the OutlookSpy tool on Windows10. The result was the same and it looks like the headers were removed by the save message operation.
The details are provided below:
Open Compose, type subject, save message using ctrl+S or pressing button with disk image. Message created in the draft folder
Navigate to the message in the draft folder. Open OutlookSpy EWS Request pad and send the following EWS GetItem request to find a ChangeKey. Current Item Id is provided in the EWS Request pad
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<soap:Header>
<t:RequestServerVersion Version="Exchange2010"/>
</soap:Header>
<soap:Body>
<GetItem
xmlns="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<ItemShape>
<t:BaseShape>IdOnly</t:BaseShape>
</ItemShape>
<ItemIds>
<t:ItemId Id="AAMkAGQ2NjU3NGQ2LTFjMGItNGM1ZC1hMjMzLTM1YjUzYzYyZDY3NABGAAAAAABOqCUOqEzcRIky8XqnjNqxBwCNVxNVF2AuQZAWaNgbSGc1AAAAAAEPAACNVxNVF2AuQZAWaNgbSGc1AADrvkZMAAA="/>
</ItemIds>
</GetItem>
</soap:Body>
</soap:Envelope>
- The response message returned the current ChangeKey
<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<h:ServerVersionInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" Version="V2018_01_08" MinorBuildNumber="15" MajorBuildNumber="5081" MinorVersion="20" MajorVersion="15"/>
</s:Header>
<s:Body>
<m:GetItemResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
<m:ResponseMessages>
<m:GetItemResponseMessage ResponseClass="Success">
<m:ResponseCode>NoError</m:ResponseCode>
<m:Items>
<t:Message>
<t:ItemId ChangeKey="CQAAABYAAACNVxNVF2AuQZAWaNgbSGc1AADrDEAU" Id="AAMkAGQ2NjU3NGQ2LTFjMGItNGM1ZC1hMjMzLTM1YjUzYzYyZDY3NABGAAAAAABOqCUOqEzcRIky8XqnjNqxBwCNVxNVF2AuQZAWaNgbSGc1AAAAAAEPAACNVxNVF2AuQZAWaNgbSGc1AADrvkZMAAA="/>
</t:Message>
</m:Items>
</m:GetItemResponseMessage>
</m:ResponseMessages>
</m:GetItemResponse>
</s:Body>
</s:Envelope>
- Send the following EWS UpdateItem request to set a custom x-header. Use the ChangeKey received in the previous step
<soap:Body>
<UpdateItem MessageDisposition="SaveOnly" ConflictResolution="AlwaysOverwrite"
xmlns="http://schemas.microsoft.com/exchange/services/2006/messages">
<ItemChanges>
<t:ItemChange>
<t:ItemId Id="AAMkAGQ2NjU3NGQ2LTFjMGItNGM1ZC1hMjMzLTM1YjUzYzYyZDY3NABGAAAAAABOqCUOqEzcRIky8XqnjNqxBwCNVxNVF2AuQZAWaNgbSGc1AAAAAAEPAACNVxNVF2AuQZAWaNgbSGc1AADrvkZMAAA="
ChangeKey="CQAAABYAAACNVxNVF2AuQZAWaNgbSGc1AADrDEAU"/>
<t:Updates>
<t:SetItemField>
<t:ExtendedFieldURI DistinguishedPropertySetId="InternetHeaders" PropertyName="x-custom-header1" PropertyType="String"/>
<t:Message>
<t:ExtendedProperty>
<t:ExtendedFieldURI DistinguishedPropertySetId="InternetHeaders" PropertyName="x-custom-header1" PropertyType="String"/>
<t:Value>yes</t:Value>
</t:ExtendedProperty>
</t:Message>
</t:SetItemField>
</t:Updates>
</t:ItemChange>
</ItemChanges>
</UpdateItem>
</soap:Body>
</soap:Envelope>
- The response to the UpdateItem request shows Success/NoError with 0 conflicts
<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<h:ServerVersionInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" Version="V2018_01_08" MinorBuildNumber="15" MajorBuildNumber="5081" MinorVersion="20" MajorVersion="15"/>
</s:Header>
<s:Body>
<m:UpdateItemResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
<m:ResponseMessages>
<m:UpdateItemResponseMessage ResponseClass="Success">
<m:ResponseCode>NoError</m:ResponseCode>
<m:Items>
<t:Message>
<t:ItemId ChangeKey="CQAAABYAAACNVxNVF2AuQZAWaNgbSGc1AADrDECs" Id="AAMkAGQ2NjU3NGQ2LTFjMGItNGM1ZC1hMjMzLTM1YjUzYzYyZDY3NABGAAAAAABOqCUOqEzcRIky8XqnjNqxBwCNVxNVF2AuQZAWaNgbSGc1AAAAAAEPAACNVxNVF2AuQZAWaNgbSGc1AADrvkZMAAA="/>
</t:Message>
</m:Items>
<m:ConflictResults>
<t:Count>0</t:Count>
</m:ConflictResults>
</m:UpdateItemResponseMessage>
</m:ResponseMessages>
</m:UpdateItemResponse>
</s:Body>
</s:Envelope>
- Send the following EWS GetItem request to check that the custom x-header was set up. Use the ChangeKey received in the previous step
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<soap:Header>
<t:RequestServerVersion Version="Exchange2010"/>
</soap:Header>
<soap:Body>
<GetItem
xmlns="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<ItemShape>
<t:AdditionalProperties>
<t:FieldURI FieldURI="item:Subject" />
<t:ExtendedFieldURI DistinguishedPropertySetId="InternetHeaders" PropertyName="x-custom-header1" PropertyType="String" />
</t:AdditionalProperties>
</ItemShape>
<ItemIds>
<t:ItemId Id="AAMkAGQ2NjU3NGQ2LTFjMGItNGM1ZC1hMjMzLTM1YjUzYzYyZDY3NABGAAAAAABOqCUOqEzcRIky8XqnjNqxBwCNVxNVF2AuQZAWaNgbSGc1AAAAAAEPAACNVxNVF2AuQZAWaNgbSGc1AADrvkZMAAA="
ChangeKey="CQAAABYAAACNVxNVF2AuQZAWaNgbSGc1AADrDECs" />
</ItemIds>
</GetItem>
</soap:Body>
</soap:Envelope>
- The GetItem response contains the custom x-header which was set up in the step 3
<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<h:ServerVersionInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" Version="V2018_01_08" MinorBuildNumber="15" MajorBuildNumber="5081" MinorVersion="20" MajorVersion="15"/>
</s:Header>
<s:Body>
<m:GetItemResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
<m:ResponseMessages>
<m:GetItemResponseMessage ResponseClass="Success">
<m:ResponseCode>NoError</m:ResponseCode>
<m:Items>
<t:Message>
<t:ItemId ChangeKey="CQAAABYAAACNVxNVF2AuQZAWaNgbSGc1AADrDECs" Id="AAMkAGQ2NjU3NGQ2LTFjMGItNGM1ZC1hMjMzLTM1YjUzYzYyZDY3NABGAAAAAABOqCUOqEzcRIky8XqnjNqxBwCNVxNVF2AuQZAWaNgbSGc1AAAAAAEPAACNVxNVF2AuQZAWaNgbSGc1AADrvkZMAAA="/>
<t:Subject>test ews 3</t:Subject>
<t:ExtendedProperty>
<t:ExtendedFieldURI PropertyType="String" PropertyName="x-custom-header1" DistinguishedPropertySetId="InternetHeaders"/>
<t:Value>yes</t:Value>
</t:ExtendedProperty>
</t:Message>
</m:Items>
</m:GetItemResponseMessage>
</m:ResponseMessages>
</m:GetItemResponse>
</s:Body>
</s:Envelope>
In the compose window type something in the message body and save the message using ctrl+S or pressing button with disk image
The save operation in the previous step will modify the item ChangeKey. Send the following GetItem request to get a new ChangeKey
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<soap:Header>
<t:RequestServerVersion Version="Exchange2010"/>
</soap:Header>
<soap:Body>
<GetItem
xmlns="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<ItemShape>
<t:BaseShape>IdOnly</t:BaseShape>
</ItemShape>
<ItemIds>
<t:ItemId Id="AAMkAGQ2NjU3NGQ2LTFjMGItNGM1ZC1hMjMzLTM1YjUzYzYyZDY3NABGAAAAAABOqCUOqEzcRIky8XqnjNqxBwCNVxNVF2AuQZAWaNgbSGc1AAAAAAEPAACNVxNVF2AuQZAWaNgbSGc1AADrvkZMAAA=" />
</ItemIds>
</GetItem>
</soap:Body>
</soap:Envelope>
- The successful response is returning the new ChangeKey
<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<h:ServerVersionInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" Version="V2018_01_08" MinorBuildNumber="15" MajorBuildNumber="5081" MinorVersion="20" MajorVersion="15"/>
</s:Header>
<s:Body>
<m:GetItemResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
<m:ResponseMessages>
<m:GetItemResponseMessage ResponseClass="Success">
<m:ResponseCode>NoError</m:ResponseCode>
<m:Items>
<t:Message>
<t:ItemId ChangeKey="CQAAABYAAACNVxNVF2AuQZAWaNgbSGc1AADrDEDV" Id="AAMkAGQ2NjU3NGQ2LTFjMGItNGM1ZC1hMjMzLTM1YjUzYzYyZDY3NABGAAAAAABOqCUOqEzcRIky8XqnjNqxBwCNVxNVF2AuQZAWaNgbSGc1AAAAAAEPAACNVxNVF2AuQZAWaNgbSGc1AADrvkZMAAA="/>
</t:Message>
</m:Items>
</m:GetItemResponseMessage>
</m:ResponseMessages>
</m:GetItemResponse>
</s:Body>
</s:Envelope>
- Send the following EWS GetItem request to check that the custom x-header is still in place. Use the ChangeKey received in the previous step
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<soap:Header>
<t:RequestServerVersion Version="Exchange2010"/>
</soap:Header>
<soap:Body>
<GetItem
xmlns="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<ItemShape>
<t:AdditionalProperties>
<t:FieldURI FieldURI="item:Subject" />
<t:ExtendedFieldURI DistinguishedPropertySetId="InternetHeaders" PropertyName="x-custom-header1" PropertyType="String" />
</t:AdditionalProperties>
</ItemShape>
<ItemIds>
<t:ItemId Id="AAMkAGQ2NjU3NGQ2LTFjMGItNGM1ZC1hMjMzLTM1YjUzYzYyZDY3NABGAAAAAABOqCUOqEzcRIky8XqnjNqxBwCNVxNVF2AuQZAWaNgbSGc1AAAAAAEPAACNVxNVF2AuQZAWaNgbSGc1AADrvkZMAAA="
ChangeKey="CQAAABYAAACNVxNVF2AuQZAWaNgbSGc1AADrDEDV" />
</ItemIds>
</GetItem>
</soap:Body>
</soap:Envelope>
- The received GetItem response doesn't contain our custom x-header
<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<h:ServerVersionInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" Version="V2018_01_08" MinorBuildNumber="15" MajorBuildNumber="5081" MinorVersion="20" MajorVersion="15"/>
</s:Header>
<s:Body>
<m:GetItemResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
<m:ResponseMessages>
<m:GetItemResponseMessage ResponseClass="Success">
<m:ResponseCode>NoError</m:ResponseCode>
<m:Items>
<t:Message>
<t:ItemId ChangeKey="CQAAABYAAACNVxNVF2AuQZAWaNgbSGc1AADrDEDV" Id="AAMkAGQ2NjU3NGQ2LTFjMGItNGM1ZC1hMjMzLTM1YjUzYzYyZDY3NABGAAAAAABOqCUOqEzcRIky8XqnjNqxBwCNVxNVF2AuQZAWaNgbSGc1AAAAAAEPAACNVxNVF2AuQZAWaNgbSGc1AADrvkZMAAA="/>
<t:Subject>test ews 3</t:Subject>
</t:Message>
</m:Items>
</m:GetItemResponseMessage>
</m:ResponseMessages>
</m:GetItemResponse>
</s:Body>
</s:Envelope>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论