通过 api 以 Angular 10 下载 Outlook 附件

问题描述

我正在尝试访问 Outlook 邮件 API 并尝试下载邮件中的附件。对于较小的附件,它工作正常。对于超过 1MB 的内容,它只是失败了。

async downloadAttachment(mail: ET.IoUtlookMailItem,att: ET.IoUtlookMailAttachment) {

  this.graphService.getRawAttachment(mail.id,att.attachmentId).then(resp => {
    // saveAs is from file-saver for blob saving
    saveAs(resp,att.attachmentName);
  });
}

async getRawAttachment(messageid: string,attachmentid: string): Promise<any> {
  try {
    let result = await this.graphClient
        .api('/me/messages/' + messageid + '/attachments/' + attachmentid + '/$value')
        .get();
      return result;
  } catch (error) {
    console.log(error);  
  }
}

Devtools 显示为响应

ReadableStream
locked: false
__proto__: ReadableStream

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)