【发布时间】: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 ScriptLab:appsource.microsoft.com/en-us/product/office/… 并使用“使用 EWS 发送消息”示例查看您的 xml 格式是否正确。这里还记录了一个示例 EWS GetFolder 请求:docs.microsoft.com/en-us/exchange/client-developer/…
-
另外,我认为您需要在 EWS 请求中使用“deleteditems”DistinguishedFolderId。
-
@OutlookAdd-insTeam-MSFT 将其更改为“deleteditems”时会出现错误“请求无效”
-
@OutlookAdd-insTeam-MSFT 这是我的代码gist.github.com/mokhakh/f22900b890f27c2112aa5655b5506646
标签: outlook office-js exchangewebservices outlook-web-addins