Comments (12)
@guzman-rc , could you please provide a video demonstrating the issue you're experiencing, along with the logs, to help us better understand the problem?
from office-js.
I will try to create a video, in the meantime I will explain the operation of the example Addin.
The objective of this Addin is to eliminate the metadata of the attached files, for this purpose, for each file that the user attaches the following tasks will be carried out:
- OnMessageAttachmentsChanged event identifies when the file has finished attaching.
- Download the contents of the attached file.
- Remove metadata from the downloaded file.
- Remove the attached file.
- The file without metadata is attached.
See log output when attaching file 1.pdf
The error occurs when we attach 3 or more files at the same time.
We have detected that there is a problem with the function: removeAttachmentAsync, it does not remove the file and ends the process.
from office-js.
@guzman-rc Can you share the handler function that is getting called for the event?
from office-js.
You can install the Addin to test it, the manifest file is available from the url:
https://www.adarsus.com/addin/outlook_event/manifest.xml
All the code is available from the file:
https://www.adarsus.com/addin/outlook_event/commands.js
The function called for the OnMessageAttachmentsChanged event is: onMessageAttachmentsChangedHandler
from office-js.
@guzman-rc
From my understanding this is the same issue like #4646 where the handler for OnMessageAttachmentsChanged itself is not getting triggered in certain scenarios when multiple files are attached, and is not specific to removeAttachmentAsync API as such, can you please confirm the same? If yes, we can close this issue as duplicate.
from office-js.
from office-js.
Hi @guzman-rc, I am able to reproduce the issue with the manifest you shared, however, I don't see it as a shortcoming of the removeAttachmentAsync
API in itself. Consider the below example:
const attachments = [
{"id":"AAkALgAAAAAAHYQDEapmEc2byACqAC/EWg0AF1DUX4ZWa0KEdGEzihNfpQACYSmLqQAAARIAEACiGPuEZvAmQZTeWzmA4gqn","name":"img1.png","contentType":"image/png","size":481031,"attachmentType":"file","isInline":false},
{"id":"AAkALgAAAAAAHYQDEapmEc2byACqAC/EWg0AF1DUX4ZWa0KEdGEzihNfpQACYSmLqQAAARIAEABINoB+ZcOKQo3CwahJs/gU","name":"img2.png","contentType":"image/png","size":587031,"attachmentType":"file","isInline":false},
{"id":"AAkALgAAAAAAHYQDEapmEc2byACqAC/EWg0AF1DUX4ZWa0KEdGEzihNfpQACYSmLqQAAARIAEAAUYVwHLqpaSKUiQ56g4KtN","name":"img3.png","contentType":"image/png","size":998554,"attachmentType":"file","isInline":false}
]
for (const item of attachments) {
const id = item.id;
// Remove an attachment
Office.context.mailbox.item.removeAttachmentAsync(
id,
{
"asyncContext": { foo: 6, bar: 28 }
},
function (asyncResult) {
showMessage(JSON.stringify(asyncResult));
}
);
}
In this case, the removeAttachmentAsync
API is successfully able to remove all the 3 files (and correspondingly, three OnMessageAttachmentsChanged
events are fired for the corresponding files, with attachmentStatus
set to removed
. I believe you are running into a race condition due to the parallel flow of execution. I would suggest you re-look the way you are handling the asynchronous operations. Maybe instead of immediately reacting to OnMessageAttachmentsChanged
finishing attaching the file, add a delay, process multiple such events together, and then correspondingly trigger the removeAttachmentAsync
API.
Let me know your thoughts.
from office-js.
Hi @kumarshrey-msft,
For each OnMessageAttachmentsChanged event of type Added the following tasks are executed:
- Download the contents of the attached file.
- Remove metadata from the downloaded file.
- Remove the attached file.
- The file without metadata is attached.
As you can see, from the moment the OnMessageAttachmentsChanged event is fired until the removeAttachmentAsync function is invoked there is already a delay in the execution of the tasks:
- Download the contents of the attached file and
- Remove metadata from the downloaded file.
You propose to add an extra delay before invoking the removeAttachmentAsync function, how long?
from office-js.
@guzman-rc As a workaround can you try to ensure that removeAttachmentAsync calls are made sequentially from your side and see if that solves the issue?
from office-js.
It is not possible to execute sequentially removeAttachmentAsync, the processes:
- Download the contents of the attached file.
- Remove metadata from the downloaded file.
- Remove the attached file.
- The file without metadata is attached.
Must run every time OnMessageAttachmentsChanged event is fired.
from office-js.
Yes, I understand that. By sequential I mean using promise or something similar to ensure you make only one call to removeAttachmentAsync at a time.
from office-js.
It should not be a problem to invoke removeAttachment simultaneously, just make sure that the file has been attached successfully before you can invoke removeAttachment.
from office-js.
Related Issues (20)
- body.clear() not working for content controls HOT 3
- How to make slide active Or How to insert image using index HOT 4
- Addin sample not showing in new look outlook and browsers. HOT 5
- Identifying Usage of New Outlook in Office-js Add-ins HOT 1
- Not able to sideload outlook addin. in macbook there is no option to add the manifest file HOT 5
- Inserting Signature with the OnMessageSend event duplicates the signature
- The identity API is not supported for this add-in in online Word HOT 2
- Excel Online: calculation state can get stuck in Pending state when workbook contains charts HOT 3
- IP Address Range Needed for Microsoft Office Add-in Validation Process
- Office API messageParent Outlook on android doesn't work
- NAA: Unable to acquire access token for event-based activation (onMessageSend) HOT 2
- Outlook addin using Bootstrap modal or offcanvas bleeds through on Mac version of Outlook. Classic and New Outlook for Mac. HOT 2
- [Word API] Document.compare: ability to specify Original and Revised document?
- Outlook NAA issue: "Something went wrong. [7q6cl]" Error HOT 5
- Web Outlook provides improper attachment data if attachment is still uploading to the email HOT 2
- [Question] Is it safe to use `CustomFunctions.delayinitialization()`
- New Outlook - emails stuck in outlook at queued or draft status HOT 3
- context.application.createDocument works only first time HOT 1
- WorkBook level Define name is getting corrupted while reopening excel using base64
- In Outlook, getAllInternetHeadersAsync works on an item in the Inbox, but not the sent folder
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from office-js.