mspiess's avatar
mspiess
Brass Contributor
Jun 29, 2022
Status:
New

Allow .msg file export through JS add-in API in Outlook-Desktop

I'd like to create an add-in which create a .msg file of an email and sends it to a remote server for archival purposes.
Outlook already can create .msg files through the "Save as..." dialog but this functionality is not exposed to the Office API.

I could access all relevant information through the API and create an .eml file for example (or use EWS/graph-API for that), but I'd prefer to leverage the existing outlook functionality.

 

I suggest a method "getMsgFileAsync( options: Office.AsyncContextOptions, callback?: (asyncResult: Office.AsyncResult<ArrayBuffer>) => void): void" on the "Office.context.mailbox.item" object.

As far as permissions go, "ItemRead" should suffice.

17 Comments

  • Rich-E's avatar
    Rich-E
    Copper Contributor

    A native API would be fantastic! If you can't wait, as mentioned by OP, a workaround is to implement the EML format yourself (which is really just an IMF text file). It was a bit annoying, but doable (and totally worth it!)...

     

    1. item.getAllInternetHeadersAsync()
    2. extract MIME boundary from headers to separate messages below
    3. item.body.getAsync(Office.CoercionType.Html) & base64 encode
    4. item.body.getAsync(Office.CoercionType.Text) & base64 encode
    5. iterate through item.attachments & item.getAttachmentContentAsync()
    6. upload file
  • Jim_Neill's avatar
    Jim_Neill
    Copper Contributor

    This ability is critical to our workflow and with the new version of Outlook killing off VSTO and VBA add-in options there is no other way that I've found to accomplish what we've been doing for decades. Please consider adding this capability prior to release of the "New Outlook". 

  • sznorbert1107's avatar
    sznorbert1107
    Copper Contributor

    I am also interested in this topic.

    It would be a great feature to have because it would make it so much easier to create an EML and send to a 3rd party server. We always struggle implementing this, because we must support this on every platform and there are lot of code challanges on different platforms.

    Also it would be great to have this possibility on compose sidebar as well while composing an email.

    Thanks!

  • Stbzzz's avatar
    Stbzzz
    Copper Contributor

    Any chance on a comment on this one?

    Is this possible or is it something that the Office API will never look to support?

    Thanks!