Outlook 加载项:使用 EWS 获取共享邮箱 ItemAttachment
Outlook add-in : Get shared mailbox ItemAttachment using EWS
我们的 outlook 加载项在大多数情况下都适用于共享邮箱,除非电子邮件中的附件类型为“Office.MailboxEnums.AttachmentType.Item
”,例如“.msg
”文件。
Environment is Outlook web and desktop.
我们主要通过 REST 获取所有附件内容,因为它们被 returned 为 base-64,但是对于“AttachmentType.Item
”,正文是电子邮件正文而不是 base-64。在这种情况下,我们调用 EWS 以下载该附件,处理正文和 return 作为 byte[];
我们目前遇到的问题是,当共享邮箱上的附件类型为“.msg”时,EWS return 出现错误“ErrorAccessDenied
”,这很奇怪,因为,其他附件已下载,我们已确保通过“TargetMailbox
”
我们通过以下方式获取目标邮箱:https://docs.microsoft.com/en-us/office/dev/add-ins/outlook/delegate-access
一旦我们有了 accessToken 和 targetMailbox,我们就调用后端
GetData(token, Id){
let sharedMailBox = GetTargetMailbox(token);
return this.$http.post("DownloadAttachment", {
token: sharedMailBox.token,
url: Office.context.mailbox.ewsUrl,
attachmentId: Id,
mailbox: sharedMailBox.mailbox
}, {
responseType: 'arraybuffer',
}).then(response => response.data);
}
后端
DownloadAttachment(Request request){
var service = new ExchangeService
{
Credentials = request.token,
Url = request.url
};
if (request.mailbox != "")
{
FolderId SharedMailbox = new FolderId(WellKnownFolderName.Inbox, request.TargetMailbox);
ItemView itemView = new ItemView(1);
service.FindItems(SharedMailbox, itemView); //This throws ErrorAccessDenied
}
//do other stuff and return data
}
不确定,如何获取共享邮箱的 itemAttachment。
共享邮箱不支持 EWS,只支持 REST。我们的文档中可能遗漏了这一点。我们会更新它。要通过 REST 获取项目附件,请遵循 https://docs.microsoft.com/en-us/graph/outlook-get-mime-message
中的“获取附加到 Outlook 项目或组的 Outlook 邮件的 MIME 内容 post”
我们的 outlook 加载项在大多数情况下都适用于共享邮箱,除非电子邮件中的附件类型为“Office.MailboxEnums.AttachmentType.Item
”,例如“.msg
”文件。
Environment is Outlook web and desktop.
我们主要通过 REST 获取所有附件内容,因为它们被 returned 为 base-64,但是对于“AttachmentType.Item
”,正文是电子邮件正文而不是 base-64。在这种情况下,我们调用 EWS 以下载该附件,处理正文和 return 作为 byte[];
我们目前遇到的问题是,当共享邮箱上的附件类型为“.msg”时,EWS return 出现错误“ErrorAccessDenied
”,这很奇怪,因为,其他附件已下载,我们已确保通过“TargetMailbox
”
我们通过以下方式获取目标邮箱:https://docs.microsoft.com/en-us/office/dev/add-ins/outlook/delegate-access
一旦我们有了 accessToken 和 targetMailbox,我们就调用后端
GetData(token, Id){
let sharedMailBox = GetTargetMailbox(token);
return this.$http.post("DownloadAttachment", {
token: sharedMailBox.token,
url: Office.context.mailbox.ewsUrl,
attachmentId: Id,
mailbox: sharedMailBox.mailbox
}, {
responseType: 'arraybuffer',
}).then(response => response.data);
}
后端
DownloadAttachment(Request request){
var service = new ExchangeService
{
Credentials = request.token,
Url = request.url
};
if (request.mailbox != "")
{
FolderId SharedMailbox = new FolderId(WellKnownFolderName.Inbox, request.TargetMailbox);
ItemView itemView = new ItemView(1);
service.FindItems(SharedMailbox, itemView); //This throws ErrorAccessDenied
}
//do other stuff and return data
}
不确定,如何获取共享邮箱的 itemAttachment。
共享邮箱不支持 EWS,只支持 REST。我们的文档中可能遗漏了这一点。我们会更新它。要通过 REST 获取项目附件,请遵循 https://docs.microsoft.com/en-us/graph/outlook-get-mime-message
中的“获取附加到 Outlook 项目或组的 Outlook 邮件的 MIME 内容 post”