简体   繁体   中英

Office-js: How I can reply automatically with Outlook Web Add-in?

I'm using Outlook Web Add-in. I need a way to send an email automatically. Something similar to this:

var item = Office.context.mailbox.item;
item.displayReplyAllForm("Default Message");

but without showing the Reply Form. I need to send a message directly and maybe only show a message like "replying... please wait" or something similar when I click the button.

How I can do that? Please help and thanks a lot.

You cannot do this from the JavaScript library directly. You would need to use Microsoft Graph API to handle sending the message. You can find instruction on how to do this in the documentation under Use the Outlook REST APIs from an Outlook add-in .

There are couple of solution one is with graph and another is with exchange api. For graph you need to little bit of extra work to get the token and auth flow working.

The other approach is to use exchange API, you don't need to do anything to do these calls you already have the authentication setup needed for you in dong this call.

Please see this documentation for the more details.

https://msdn.microsoft.com/en-us/library/office/dd633704(v=exchg.80).aspx

https://docs.microsoft.com/en-us/outlook/add-ins/web-services

If you want a client only solution you can directly call the Office.context.mailbox.makeEwsRequestAsync API (refer documentation here: https://dev.office.com/reference/add-ins/outlook/1.5/Office.context.mailbox?product=outlook )

To construct the soap request to be used in makeEWSRequest, you can use: https://msdn.microsoft.com/en-us/library/office/dn600292%28v=exchg.150%29.aspx?f=255&MSPPError=-2147217396

Note that makeEWSRequest is not supported in mobile clients.

You should ideally request for a graph token using getCallbackTokenAsync API and then use the graph APIs with the token to send the email. This should work on all clients and is a preferred way to accomplish this scenario.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM