download outlook attachment via api in angular 10

HPrakash 1 Reputation point
2021-03-18T14:01:40.717+00:00

I am trying to access outlook mail api and trying to download attachment in mails. For smaller attachments, it works fine. For something more than 1MB it just fails.

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);
}
}

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,420 questions
{count} votes