【问题标题】:return a Count of emails inside Trash folder返回垃圾文件夹中的电子邮件计数
【发布时间】:2022-01-10 06:22:11
【问题描述】:

如何使用 Outlook Web 加载项获取垃圾文件夹中的电子邮件数量 我尝试使用 EWS xml,但它显示错误

let xml =
    '<?xml version="1.0" encoding="utf-8"?>\n' +
    '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="https://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="https://schemas.xmlsoap.org/soap/envelope/">\n' +
    '  <soap:Header>\n' +
    '    <t:RequestServerVersion Version="Exchange2007_SP1" />\n' +
    '  </soap:Header>\n' +
    '  <soap:Body>\n' +
    '    <m:GetFolder>\n' +
    '      <m:FolderShape>\n' +
    '        <t:BaseShape>IdOnly</t:BaseShape>\n' +
    '      </m:FolderShape>\n' +
    '      <m:FolderIds>\n' +
    '        <t:DistinguishedFolderId Id="inbox" />\n' +
    '      </m:FolderIds>\n' +
    '    </m:GetFolder>\n' +
    '  </soap:Body>\n' +
    '</soap:Envelope>';


var mailbox = Office.context.mailbox;
mailbox.makeEwsRequestAsync(xml, function(result) {
  console.log(result);
  //var response = $.parseXML(result.value);
  //var extendedProps = response.getElementsByTagName("ExtendedProperty")
});

结果:

message: "The remote server returned an error: (500) Internal Server Error."

【问题讨论】:

标签: outlook office-js exchangewebservices outlook-web-addins


【解决方案1】:

请求PR_CONTENT_COUNTMAPI 属性:

<FolderShape>
  <t:BaseShape>IdOnly</t:BaseShape>
  <t:AdditionalProperties>
    <t:ExtendedFieldURI PropertyType="Integer" PropertyTag="0x3602"/>
  </t:AdditionalProperties>
</FolderShape>

或者你可以请求TotalCount属性:

<t:AdditionalProperties>
  <t:FieldURI FieldURI="folder:TotalCount"/>
</t:AdditionalProperties>

更新:我无法执行您上面的请求(同样的错误),但在OutlookSpy 中的“EWS 请求板”中可以正常执行以下操作:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
               xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
  <soap:Header>
    <t:RequestServerVersion Version="Exchange2007_SP1"/>
  </soap:Header>
  <soap:Body>
    <GetFolder xmlns="http://schemas.microsoft.com/exchange/services/2006/messages"
               xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
      <FolderShape>
        <t:BaseShape>IdOnly</t:BaseShape>
        <t:AdditionalProperties>
          <t:ExtendedFieldURI PropertyType="Integer" PropertyTag="0x3602"/>
        </t:AdditionalProperties>
      </FolderShape>
      <FolderIds>
        <t:DistinguishedFolderId Id="deleteditems"/>
      </FolderIds>
    </GetFolder>
  </soap:Body>
</soap:Envelope>

【讨论】:

  • 将上面的标签附加到我的 xml 和同样的错误:(
  • docs.microsoft.com/en-us/exchange/client-developer/… 我尝试使用此 xml 并收到错误“请求无效”:(
  • 如果您从 OutlookSpy(GetFolder 或“EWS Request Pad”)执行该请求,是否会收到相同的错误?
  • 查看上面的更新答案
猜你喜欢
  • 2011-06-29
  • 1970-01-01
  • 1970-01-01
  • 2015-09-01
  • 2017-03-02
  • 2011-04-17
  • 2015-06-23
  • 2011-07-12
相关资源
最近更新 更多