M365: Microsoft Graph – Part 10 – Send Email using Graph API from Console Application (Background Job)

Hi All,

LIFE IS BEAUTIFUL 🙂 Today with MS Graph, my favorite feature of M365 🙂

In following previous articles we have discussed regarding Microsoft Graph. Today again long time back new article on MS GRAPH 🙂

In today’s article we will simple discuss steps to send an email from console application (background job) using Graph API.


M365 - Microsoft Graph - "Mail.Send" permission giving to Azure App
Fig1: M365 – Microsoft Graph – “Mail.Send” permission assigning to Azure App

Detailed Steps:

  • Once we have Azure App with respective permission, we are ready to consume the GraphServiceClient (Microsoft.Graph) class which requires instance of IAuthenticationProvider (Microsoft.Graph ) as
  • We have our own AuthProvider class inherited from IAuthenticationProvider interface and implementing AuthenticateRequestAsync() method as
  • Here we are using X509Certificate2 certificate and AppId for authentication. We are not using Client Secret key.
  • Create the Message (Microsoft.Graph.Message) object as
  • Call SendMail method of GraphServiceClient class as
  • When above request is made, method “AuthenticateRequestAsync” of AuthProvider class is getting called.
  • If we don’t want to send email on be half of specific user, we could use shared email box as well.


Thanks a lot for reading 🙂 Enjoy the beautiful LIFE 🙂 HAVE A SAFE LIFE 🙂 TAKE CARE 🙂


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.