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 Security | Microsoft Graph
{count} votes

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.