return 垃圾文件夹中的电子邮件计数

return a Count of emails inside Trash folder

如何使用 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."

请求 PR_CONTENT_COUNT MAPI 属性:

<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>

Update:我无法执行您上面的请求(同样的错误),但是下面的 OutlookSpy 中的“EWS Request Pad”工作正常(我是它的作者):

<?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>