OfficeDev / office-js-docs-reference

Microsoft Office JavaScript API Reference
https://learn.microsoft.com/javascript/api/overview
MIT License
105 stars 63 forks source link

How to set CustomProperty and recognize emails generated with displayNewMessageFormAsync in an Outlook add-in? #1943

Closed CodeCube0 closed 1 month ago

CodeCube0 commented 1 month ago

Hi,

I have a question regarding the use of the displayNewMessageFormAsync function to generate new emails in an Outlook add-in. How can I set CustomProperty for an email generated with this function? Additionally, is there a way to recognize if an email was generated using displayNewMessageFormAsync?

Thanks in advance for your help!

AlexJerabek commented 1 month ago

Hi @CodeCube0,

Thank you for the question. Let me assign @samantharamon to take a look.

samantharamon commented 1 month ago

Hi @CodeCube0,

To set custom properties in the newly created message, in the callback function of displayNewMessageFormAsync, call Office.context.mailbox.item.loadCustomPropertiesAsync. You can then use the set method on the returned CustomProperties object. For further guidance, see Get and set add-in metadata for an Outlook add-in.

There isn't a way to identify whether a message was generated using the displayNewMessageFormAsync method. If this is a functionality you'd like to see in the product, we recommend requesting it on the Microsoft 365 Developer Platform Ideas Forum.

CodeCube0 commented 1 month ago

Okay thank you. I will definitely write in the forum to add features