Search code examples
office-jsoutlook-web-addins

Office JS - Edit txt file before attaching


I would like to attach a txt file to an email and I want to be able to dynamically control the content of the txt file before attaching it. I am wanting to do this in an outlook add-in so am using office js. I have seen this doco here.

The addFileAttachmentAsync method only accepts a uri so wasn't sure if I could use this for my purposes unless I store the basic empty file somewhere and can somehow manipulate that file before attaching it.

I have seen also that there is a addFileAttachmentFromBase64Async method, which seems more useful but it needs api requirement set 1.8 which I think will preclude a lot of my users from being eligible to use it.

I'd be grateful for any suggestions.


Solution

  • The attachment APIs you mentioned (addFileAttachmentAsync and addFileAttachmentFromBase64Async) do not modify the content of the attachment. To achieve your scenario, you would have to create a text file and use one of the attachment APIs to attach it.

    Currently, the feature to modify an attachment from an Outlook add-in is not a part of the product. We track Outlook add-in feature requests on our user-voice page. Please add your request there. Feature requests on user-voice are considered, when we go through our planning process.