OfficeDev / office-js

A repo and NPM package for Office.js, corresponding to a copy of what gets published to the official "evergreen" Office.js CDN, at https://appsforoffice.microsoft.com/lib/1/hosted/office.js.
https://learn.microsoft.com/javascript/api/overview
Other
670 stars 96 forks source link

attachment id coming in GUID format via office js(Office.context.mailbox.item.getAttachmentsAsync) #4881

Closed soumyamondal-accenture closed 4 days ago

soumyamondal-accenture commented 1 week ago

We are developing an web addin for Outlook platforms using Office js framework , wherein we extract the attachment content of a composed mail . We try to fetch the metadata(attachment Id, name, size, type) of the attachments via Office.context.mailbox.item.getAttachmentsAsync but sometimes the attachment id comes in GUID format. If the attachment id is received in GUID format then the respective attchment base64 content is corrupted(wither blank or in html format).

Environment

Expected behavior

The attchment id extracted via should not be coming in GUID format.

Current behavior

We try to fetch the metadata(attachment Id, name, size, type) of the attachments via Office.context.mailbox.item.getAttachmentsAsync but sometimes the attachment id comes in GUID format. If the attachment id is received in GUID format then the respective attchment base64 content is corrupted(wither blank or in html format).

Steps to reproduce

Compose a new email Add reipcients Add subject and body Click on send Once the pane(generic taskpane of office js, we are using custom react components) is displayed with contents attach more than 4 attachments(twice happened for excel files)

Provide additional details

below is the snippet for extracting attachment metadata that we using:- attachmentData=Office.context.mailbox.item// we are passing to the callback export const fetchAttachments = async (attachmentData) => { return new Promise((resolve, reject) => { attachentData.getAttachmentsAsync(function (asyncResult) { / Handle success or error./ if (asyncResult.status !== Office.AsyncResultStatus.Succeeded) { console.error("fetchAttachments:Failed to get attachments. " + JSON.stringify(asyncResult.error)); reject(JSON.stringify(asyncResult.error)); }

  resolve(asyncResult.value);
});

}); };

Context

We are developing features where we plan to validate the attachments added as part of the our addin, in order to achieve that we need to extract the attachment content, but in this particular scenario when the attchment id comes as GUID, then the corresponding base64 content of the attchment is corrupted(either comes as html/empty/on decoding we find its not the actual attachment content).

Useful logs

PFA for screenshots,

Screenshot 2024-09-11 204332

Thank you for taking the time to report an issue. Our triage team will respond to you in less than 72 hours. Normally, response time is <10 hours Monday through Friday. We do not triage on weekends.

Screenshot 2024-09-11 204332
kumarshrey-msft commented 1 week ago

Hi @soumyamondal-accenture, I was unable to repro the scenario at my end. Can you share the addin that we can side load for testing this scenario? You can create a private repo and share it with @exextoc

microsoft-github-policy-service[bot] commented 1 week ago

This issue has been automatically marked as stale because it is marked as needing author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. Thank you for your interest in Office Add-ins!

microsoft-github-policy-service[bot] commented 4 days ago

This issue has been closed due to inactivity. Please comment if you still need assistance and we'll re-open the issue.