Home > database >  Sending a mail using 365 instance
Sending a mail using 365 instance

Time:12-08

I am developing an app on Microsoft Teams, and I would like to send a mail with an instance of a logged in user.

This means that a user logs into my Microsoft Teams app, wants to send a custom mail that the app generated, now I want to send a request to my REST API to send this mail as the user.

I could not find any relevant information regarding sending an email like this, I only found methods to send emails with supplying username/password or using the current logged user on the machine (which I can't use since I want to do that using my REST API).

Example of what I found but is irrelevant: https://www.add-in-express.com/creating-addins-blog/2011/09/02/outlook-create-send-message/

CodePudding user response:

You don't mention if your app is a Tab or a Bot app (or something else), but I'm presuming a Tab. In any case, both Bots and Tab's offer the ability to do SSO sign-in of the user, in which case you can easily get a token for the user. In your backend API, you can exchange this for an "on behalf of" (OBO) token, which lets you access the Microsoft Graph API on the user's behalf. Once that's done, you can call the "send mail" operation on Graph.

To find out more about the above, see:

  1. here for an excellent video overview on SSO with Tabs
  2. here for a blog post on how to exchange the tokens and make the graph call securely
  3. here for the specific operation in Graph (sending email)
  • Related