Closed hmuris closed 4 months ago
@hmuris - Which platform and version of outlook are you having this problem? Can you please provide a sample scriptlab snippet which will help us get a repro and investigate further?
Ok, I need a bit time, please don't close.
Here is the method to get the attachments:
private getMyAttachment(item: (Office.Item & Office.ItemCompose & Office.ItemRead & Office.Message & Office.MessageCompose & Office.MessageRead & Office.Appointment & Office.AppointmentCompose & Office.AppointmentRead), attachmentInfos: any[], index: number): Observable<any[]> { return new Observable<any[]>((observer) => { let attachments: any[] = []; if (index + 1 <= attachmentInfos.length) { item.getAttachmentContentAsync(attachmentInfos[index].id, (attachmentContentResult: any) => { if (attachmentContentResult.status !== Office.AsyncResultStatus.Failed) { let attachment = attachmentContentResult.value; let attachmentInfo = attachmentInfos[index]; attachments.push({ name: attachmentInfo.name, attachmentId: attachmentInfo.id, data: attachment.content }); this.getMyAttachment(item, attachmentInfos, index + 1).subscribe((attachmentResult) => { attachments = attachments.concat(attachmentResult); observer.next(attachments); }); } else { observer.error('Failed to get attachment content.'); } }); } else { observer.next(attachments); } }); }
and here is the call of it:
if (item && (item.getItemIdAsync === undefined || typeof item.getItemIdAsync === undefined)) { this.getMyAttachment(item, item.attachments, 0).subscribe((myAttachments)=>{ console.log('Here are attachments with no data'); }); }
The call is performed on the button click in the app.component.ts.
For the email with two attachments, I get this:
Here is the manifest.
Since the code is not formated with line breaks, here it is as a picture:
Hello, is there any news about this topic? Again, this was working without any problem, and it is no longer so.
@hmuris, what is the attachment type where you see this issue. Is it any of the blocked types listed here - https://support.microsoft.com/en-us/office/blocked-attachments-in-outlook-434752e1-02d3-4e90-9124-8b81e49a8519 ?
No, it is a png, as an inline and as regular attachment.
@hmuris Would it be possible to share a repro video. This would help us repro the issue.
We also encounter this issue. If that may help, we constantly get this issue when we try make multiple (up to 50-60) concurrent content requests.
@Suntechnick @hmuris - I understand you are having an issue with office-js api. But, are you able to download attachments directly from the email from the UI?
@ajays-msft I haven't tried it, but I assume it won't be helpful because this issue is inconsistent. What I mean is that in some cases the content is properly acquired and in some cases it isn't.
I was able to find a workaround for this issue that works as following: in case when getAttachmentContentAsync
finishes with succeeded
status and empty content, we retry the getAttachmentContentAsync
request until the proper content is acquired.
@hmuris Can you help us with the platform and version of outlook are you having this problem? Also share a repro video, it will help us understand the problem.
For us the issue was only present in Outlook for the Web.
Hi, yes, we are developing the addin, visible in manifest, which is using API version 12, meaning it cannot be desktop version, or?
I don't understand what should I record? Here is the code:
let item = Office.context.mailbox.item; if(item && item.attachments && item.attachments.length > 0){ item.getAttachmentContentAsync(item.attachments[0].id, (clbk)=>{ let attachment = clbk.value; //attachment.content is empty debugger; }); }
@hmuris @Suntechnick - You mentioned the issue is inconsistent. Is it inconsistent always for the same type of attachment?
I didn't mention that it is inconsistent. For us, it is always not delivering the content.
On Wed, Jan 17, 2024, 7:40 AM Ajay Suri @.***> wrote:
@hmuris https://github.com/hmuris @Suntechnick https://github.com/Suntechnick - You mentioned the issue is inconsistent. Is it inconsistent always for the same type of attachment?
— Reply to this email directly, view it on GitHub https://github.com/OfficeDev/office-js/issues/3897#issuecomment-1895089670, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABGP4QHQX6L66Q64Z2ADUZLYO5W43AVCNFSM6AAAAABAMTMY7SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOJVGA4DSNRXGA . You are receiving this because you were mentioned.Message ID: @.***>
@ajays-msft I'll provide more details for our case. We are attaching 59 files to the email (these 59 files are the copies of the same .doc file). Then we simultaneously request the content for ALL of the 59 attachments and for some of them we encounter the issue described in this ticket. What I meant by "inconsistency" is that the number of attachments that have empty content is arbitrary (e.g., sometimes it's 3, sometimes it's 2 and sometimes it's 6 and so on...), and the attachments that have empty content are arbitrary as well (e.g., sometimes it's attachments #2, #59 and #29; sometimes it's attachments #3 and #48 and so on...).
Not sure if that may be helpful, but we noticed that in devtools network tab, some of the attachments content requests are failed with 503 code. We are not sure that's related to the issue from this ticket because the results of getAttachmentContentAsync
requests always have a succeeded
status.
Thank you. To summarize @hmuris - getAttachmentContentAsync never works for you. Please confirm if there is any setting on the server side to block downloads for attachments in OWA. @Suntechnick - It fails certain times when you have several attachments. When you mean simultaneously request for all files, I am assuming you are waiting for attachment event to be completed, and only then trying to fetch the attachment one after another. Is that the right understanding?
@ajays-msft No, all the requests for the content are sent at the same time. Making it sequentially is not desired in our case because it will make things slower and we are already limited by the on-send event 5 minutes limit.
Thank you @Suntechnick. Noted. Is this issue reproduced in other platforms (Windows Outlook, Mac Outlook), or is this specific to Outlook in Browser?
@ajays-msft We only encountered this issue on Web Outlook. It was not replicated on Outlook Desktop.
I confirm that there is no setting blocking attachment download. I have accounts on different domains, and this does not work on either of them.
@hmuris - Getting attachments is different in read and compose. The code you pointed to will work in read mode only. For more details on getting attachments, here is the documentation.
Read Mode: https://learn.microsoft.com/en-us/office/dev/add-ins/outlook/get-attachments-of-an-outlook-item
Compose Mode: https://learn.microsoft.com/en-us/office/dev/add-ins/outlook/add-and-remove-attachments-to-an-item-in-a-compose-form
@Suntechnick - Can you please create a new github issue for your case since these are different problems?
I know it is different. It is easier to show this example. Still, this code is not working in read mode.
On Thu, Jan 18, 2024, 5:39 AM Ajay Suri @.***> wrote:
@Suntechnick https://github.com/Suntechnick - Can you please create a new github issue for your case since these are different problems?
— Reply to this email directly, view it on GitHub https://github.com/OfficeDev/office-js/issues/3897#issuecomment-1897783867, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABGP4QHZ736BVSSL4BY336LYPCRPTAVCNFSM6AAAAABAMTMY7SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOJXG44DGOBWG4 . You are receiving this because you were mentioned.Message ID: @.***>
Thanks @hmuris. Unfortunately, I am not able get a repro. Can I assume that you are able to manually download the attachment directly from OWA Mail? Please confirm.
@Suntechnick - Can you please create a new github issue for your case since these are different problems?
Not sure these are different problems because we face exactly the same issue that's described in this ticket. Checking the @hmuris code example, I think that's very similar to what I've tried to describe earlier and how it works in our addin. In short: multiple concurrent requests to get attachment's content cause some of them to unexpectedly return an empty content.
@Suntechnick - In your case it fails at times. But for @hmuris it always fails.
@ajays-msft probably my explanation was not clear enough. The issue occurs consistently under certain circumstances that I described above, but the results of this issue may wary (that's what I meant by "inconsistent behavior").
@Suntechnick - For @hmuris If the call is made 50 times, all the time it fails.
But for you it will fail some x number of times out of 50 times, and x may vary for each run. That is my understanding. That is what I meant by inconsistent failures. I agree that it you are consistently seeing inconsistent failures.
I can download attachment. Here is the example when composing the email:
public doAttachments() { let item = Office.context.mailbox.item; if (item) { item.getAttachmentsAsync((officeJSAttachments) => { item?.getAttachmentContentAsync(officeJSAttachments.value[0].id, (clbk)=>{ let attachment = clbk.value; //attachment.content is empty debugger; }); }); } }
Result is same like for reading emails.
Any news here?
We are not able to repro this issue at our end. Can you please share the test tenant at OutlookExtensibility@M365x53858506.onmicrosoft.com so that we can repro the issue and debug it at our end.
@exextoc I will modify the add-in so that you can install it on your side.
@exextoc I have found the problem. We are using makeEwsRequestAsync to save and read extended property data. In order to save data, first we have to make a request to get the change key and then the second request to set the data. The attachments were broken when we had two of these requests running at "the same time". Once we changed it to observable, and waited explicitly with second, attachments were delivered correctly.
Hello,
we have detected this problem earlier today, the method getAttachmentContentAsync which previously was delivering the content, is not doing it any more.
After calling item.getAttachmentsAsync (Compose) or getting the list of attachments from item.attachments (Read), we call item.getAttachmentContentAsync in order to get the content. Although this was working it is no longer. Question is, how can we get the content of attachments, if this changed.