How to use outlook account mailbox to send mail by my application?

Developer GZ 40 Reputation points
2024-12-10T09:56:30.4466667+00:00

I have a requirement,

which is to use an Outlook account email to send emails.

These types of email are mostly Outlook and Hotmail accounts,

They are all free email accounts and use OAuth2 authentication.

My application needs to use this type of email as a sender to send emails.

How should I proceed? What licenses are needed?

Microsoft 365 and Office | Install, redeem, activate | For business | Windows
Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

Accepted answer
  1. CarlZhao-MSFT 46,376 Reputation points
    2024-12-11T02:56:52.32+00:00

    Hi @Developer GZ

    First, you'll need to register an app in your tenant that allows personal accounts to log in.

    User's image

    Next, use the authorization code flow to authenticate your personal account and generate an access token. Note that when logging in to a user and requesting a token, you need to change /{tenant_id} to /common.

    Finally, call the POST /me/sendMail API to send the email.

    User's image

    By the way, since your users are personal or social accounts, they don't need any licenses.


    Hope this helps.

    If the reply is helpful, please click Accept Answer and kindly upvote it. If you have additional questions about this answer, please click Comment.


1 additional answer

Sort by: Most helpful
  1. Developer GZ 40 Reputation points
    2024-12-11T04:12:07.5666667+00:00

    Hi:

    CarlZhao-MSFT,Thank for your response.

    I am very glad to receive your reply. Your answer is very helpful to me.

    I would like to know what Microsoft Graph API permissions need to be granted to my application.

    For example, my manager account is ******@gzabc.onmicrosoft.com.

    Currently, my only user is administrators ******@gzabc.onmicrosoft.com

    Now, I want to send an email to ******@outlook.com as ******@outlook.com.

    We need to ******@outlook.com Join my organization as a user?

    Who obtained the access_token as ?

    it is ******@outlook.com or

    ******@gzabc.onmicrosoft.com ?

    Looking forward to your response


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.