【问题标题】:Custom x-headers are removed after the message is saved in Outlook desktop将邮件保存在 Outlook 桌面后,自定义 x-header 将被删除
【发布时间】:2022-08-08 13:45:17
【问题描述】:

我一直在开发一个 Outlook 加载项,该加载项根据与用户的交互插入自定义 x 标题。 Outlook Web 应用程序工作正常。当这些自定义 x 标头从 Outlook 桌面(Windows 10 和 macOS Monterey 版本 12.2)的消息中消失时,我遇到了问题。

环境信息:

Windows 10 Pro 版本为 21H2,OS build 19044.1469

微软 Office 专业增强版 2019

Microsoft® Outlook® 2019 MSO(版本 2110 Build 16.0.14527.20234)32 位

macOS 蒙特雷版本 12.2

Microsoft Outlook for Mac 版本 16.53 (21091200)

为了确保标头的插入成功并确定标头消失的时刻,我使用 Windows10 上的 OutlookSpy 工具手动执行了加载项逻辑。结果是一样的,看起来标题已被保存消息操作删除。

详情如下:

  1. 打开撰写,键入主题,使用 ctrl+S 保存消息或按下带有磁盘图像的按钮。在草稿文件夹中创建的消息

  2. 导航到草稿文件夹中的邮件。打开 OutlookSpy EWS 请求板并发送以下 EWS GetItem 请求以查找 ChangeKey。 EWS 请求板中提供了当前项目 ID

    <?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>
    
    1. 响应消息返回当前的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>
    
    1. 发送以下 EWS UpdateItem 请求以设置自定义 x-header。使用上一步收到的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>
    
    1. 对 UpdateItem 请求的响应显示 Success/NoError 与 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>
    
    1. 发送以下 EWS GetItem 请求以检查自定义 x-header 是否已设置。使用上一步收到的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>
    
    1. 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>
    
    1. 在撰写窗口中,在消息正文中键入内容,然后使用 ctrl+S 或按带有磁盘映像的按钮保存消息

    2. 上一步的保存操作会修改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>
    
    1. 成功的响应是返回新的 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>
    
    1. 发送以下 EWS GetItem 请求以检查自定义 x-header 是否仍然存在。使用上一步收到的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>
    
    1. 收到的 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>
    
  • 您是否尝试过使用 MS 打开支持案例?您是否检查过任何其他 Exchange 服务器版本?它是否特定于特定的 Exchange 版本?
  • 尝试改用Graph API
  • 如果图片没有更改,我建议使用 MS 打开支持案例。
  • 抱歉,我只测试了一个 Exchange 服务器版本。
  • 通常,如果您使用 EWS 修改服务器上的项目,然后在客户端上保存/发送该项目,则客户端在尝试解决冲突时会清除服务器上的更改。大多数解决方案都应该在客户端或服务器上完成所有操作,以避免此类问题。 Internet Headers Office.js API 对您有帮助吗? docs.microsoft.com/en-us/javascript/api/outlook/…

标签: outlook exchange-server outlook-addin exchangewebservices outlook-web-addins


【解决方案1】:

检查您的电子邮件流如何?与任何电子邮件网关(例如设备、Exchange Online 等)一样,因为它能够通过规则删除 x-headers。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-07-20
    • 2023-03-24
    • 1970-01-01
    • 2018-08-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多