Send email with API

nd0911 86 Reputation points


I have an office 365 account with Two Exchange emails account's, and I want to send emails via Excel VBA.

I know to write API's with VBA code, so I don't need help in this section, my problem is to configure the right settings in the Azure portal and make a connection with Postman, after this I know how to write the code in VBA.

I don't know if it's important to the configuration but I'm one man "Company", and as I said above I have office 365 account with two emails (domain emails) and I want to send Emails from one of this emails account.

The Excel file which I plan to send the email's from, lives in my personal PC so the configuration authentication can be the minimum as possible.

What have I done so far ?


  1. In the azure portal I created a new "app registration"
  2. I don't know if I did right but in the API Permissions I added permissions as you can see in the screenshot:

I don't know if I needed to select "Delegated" or "Application", for my needs...

  1. I don't know if I need it but i have created a "Client secret"

I will be happy if someone can guide me what I need to do next.

Thank you.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
1,297 questions
Microsoft Graph Users API
Microsoft Graph Users API
A Microsoft API that allows you to build compelling app experiences based on users, their relationships with other users and groups, and the resources they access for example their mails, calendars, files, administrative roles, group memberships.
720 questions
Microsoft Graph Mail API
Microsoft Graph Mail API
A Microsoft API that supports accessing data in users' primary mailboxes and in shared mailboxes.
796 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. CarlZhao-MSFT 23,031 Reputation points

    Hi @nd0911

    If you are trying to send mail on behalf of a user in the tenant, then you need to grant the application the Mail.Send application permission. From the screenshot you shared, apparently you've already done that.

    Next step you need to get application token using unattended client credentials flow.


    Finally use this token to call the /sendMail graph API to send mail on behalf of the user:


    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.