
Microsoft Graph is a powerful API that allows you to access data from Azure Active Directory (Azure AD) and Office 365. It provides a unified interface to access various Office 365 services.
With Microsoft Graph, you can retrieve email messages from your Azure tenant. This is achieved through the use of the Mail API, which allows you to read and send email messages.
To use the Mail API, you need to have the necessary permissions set up in your Azure AD tenant. This includes the "Mail.Read" and "Mail.Send" permissions, which are required to read and send email messages.
You can use the Microsoft Graph SDK to simplify the process of accessing email messages from your Azure tenant. The SDK provides a convenient and efficient way to interact with the Microsoft Graph API.
Getting Started
To get started with email from your Azure tenant, you'll need to create an Azure Active Directory (Azure AD) instance. This is the foundation for setting up email services.
Azure AD is a cloud-based identity and access management solution that allows you to manage user identities and access to your Azure resources. It's free to use and integrates well with other Azure services.
You can create an Azure AD instance by navigating to the Azure portal and clicking on the "Azure Active Directory" button. From there, you can follow the prompts to create a new instance and configure your directory settings.
Try
Try is a great way to get started with sending emails using Azure Communication Services. You can use Try Email to kick-start sending emails to your desired recipients.
To send a message, click Try Email on the left navigation panel under Email from the overview page of a provisioned Azure Communication Service resource.
Select one of the verified domains from the drop-down list to get started.
Compose the email to send, including the message subject and body.
Click Send to send the email, and you'll see "Email Sent Successfully" once it's been delivered.

You can also copy the sample Code Snippet to send an email and use it in your sample project to send notifications.
To use the Email Client library for C#, you'll need to have the following prerequisites:
- An Azure account with an active subscription.
- An Azure Email Communication Services resource created and ready with a provisioned domain.
- An active Azure Communication Services resource connected to an Email Domain and its connection string.
- The latest Azure CLI.
Getting Delivery Status
Getting Delivery Status is a crucial aspect of any email service. You can get the actual email delivery status by subscribing to the "EmailDeliveryReportReceived" event, which is generated when the email delivery is completed.
The event returns three possible delivery states: Delivered, Failed, or Quarantined. This information is essential to understand the success or failure of your email campaigns.
You can also subscribe to Email Operational logs for more detailed information about email delivery metrics. There are two types of logs available: Email Send Mail operational logs and Email Status Update operational logs.
Email Send Mail operational logs provide detailed information about send mail requests, while Email Status Update operational logs provide message and recipient level delivery status updates.
Notification
Notification is a crucial part of any online presence. You can send email from Azure, but it's not as straightforward as you might think.
Sending email from an Azure account requires some extra steps. You can't use SendGrid directly, as your account may not support it.
There are alternative services you can use to send email from Azure. For example, you can integrate with MailChimp or Mandrill using a NuGet package.
However, it's worth noting that outbound SMTP from Azure is explicitly disallowed. This means you can't use the standard SMTP protocol to send email from Azure.
If you're looking for a quick start guide on sending email from Azure, you can check out the official documentation. The link is available here: https://learn.microsoft.com/en-us/azure/communication-services/quickstarts/email/send-email?pivots=programming-language-csharp
Sending Email
You can send an email from your Azure tenant using various methods, including Microsoft Graph API, SendGrid API, and Office 365 SMTP relay. Microsoft Graph API allows you to send an email from Azure, and you can use the example PowerShell script provided in the documentation to get started.
To use SendGrid API, you'll need to submit an HTTP request to SendGrid's API endpoint URL using the Invoke-RestMethod cmdlet in PowerShell. This method communicates using HTTP, unlike SMTP. You can find more information about SendGrid Web API on the V3 Mail Send API page.
Using Office 365 SMTP relay is another option, and you can test it using PowerShell after setting up the sender address and assigning the Send As permission. Make sure to encrypt or manage your credentials securely in production scripts.
SendGrid SMTP Relay
To use SendGrid for sending emails, you'll need to know the SendGrid SMTP server address, which is smtp.sendgrid.net.
The username for SMTP authentication is always apikey.
The password to use is the value of the API key you created in SendGrid.
When sending emails, it's essential to use port 587 instead of port 25.
Only the verified sender address in SendGrid is valid to use as the sender of your emails.
Here are the essential requirements to use SendGrid SMTP relay:
- The SendGrid SMTP server address is smtp.sendgrid.net.
- The username used for SMTP authentication is always apikey.
- The password to use is the value of the API key you created in SendGrid.
- Use port 587 instead of port 25.
- Only the verified sender address in SendGrid is valid to use as the sender of your emails.
SendGrid API
You can use the SendGrid Web API V3 to send emails from Azure, which communicates using HTTP instead of SMTP.
The API endpoint URL is where the HTTP request is sent to submit the email request.
To use the SendGrid API, you'll need to update variable values such as $sendGridApiKey, $fromAddress, $toAddress, $mailSubject, and $mailMessage in a PowerShell script.
Copy and run the code in PowerShell to send the email request to SendGrid.
After running the code, check the recipient's mailbox to confirm that the test message was successfully delivered.
The SendGrid Web API can be learned more about by visiting the V3 Mail Send API page.
Using Microsoft Graph
Using Microsoft Graph to send emails from your Azure tenant is a more secure and recommended approach than using the Office 365 SMTP relay.
To use Microsoft Graph, you'll need to register an Azure AD app, which must be assigned with the Mail.Send API permission.
This permission allows you to send emails from any mailbox in your organization using REST API calls.
Microsoft Graph API is a powerful tool that enables you to automate email sending tasks in a scalable and efficient way.
To get started, you'll need to configure Microsoft Graph API, which involves creating a registered Azure AD app with the necessary permissions.
Understanding Email
Email is a widely used communication tool that allows users to send and receive messages electronically. It's a fundamental part of our digital lives.
Email accounts are created and managed within an Azure tenant, which provides a centralized platform for users to access and manage their email settings.
A user's email address is a unique identifier that distinguishes them from others within the Azure tenant.
Email messages can be sent from one user to another within the Azure tenant, and can also be sent to external recipients outside of the tenant.
Email messages are typically composed of a subject line, body, and attachments, which can include documents, images, and other files.
Frequently Asked Questions
How to send email from Azure VM?
To send email from an Azure VM, use the Azure Communication Services to create an SmtpClient with the host URL and authentication credentials, then send a MailMessage using the SmtpClient's Send method. This process enables secure email sending from your Azure environment.
Sources
- https://learn.microsoft.com/en-us/azure/communication-services/quickstarts/email/send-email
- https://stackoverflow.com/questions/17666161/sending-email-from-azure
- https://docs.extraview.com/site/extraview-23/administration-guide/advanced-menu/oauth2-email-access-tokens/microsoft-azure-email-configuration
- https://adamtheautomator.com/azure-send-email/
- https://medium.com/medialesson/how-to-send-emails-at-scale-in-net-with-the-azure-communication-service-14565d84147f
Featured Images: pexels.com