Share via

Simplest way to send email via Azure

Jax Castillo 0 Reputation points
2026-02-11T17:15:27.89+00:00

Hi Can any one explain and provide me a guidance on how to send emails through Azure platform or through outlook platform.

Azure Communication Services
{count} votes

2 answers

Sort by: Most helpful
  1. Golla Venkata Pavani 2,340 Reputation points Microsoft External Staff Moderator
    2026-02-11T18:03:16.4333333+00:00

    Hi @Jax Castillo ,

    Thank you for reaching us regarding the guidance on how to send emails using the Azure platform, specifically through Azure Communication Services.

    Create resources (if not already done):

    • Go to the Azure portal > Create a resource > Search for Communication Services > Create one.
    • Then create an Email Communication Services resource (linked or separate).
    • Verify a domain: Use Azure-managed (e.g., something.azurecomm.net) for testing, or add/verify your custom domain.
    • Reference : Prepare an Email Communication resource

    Send your first email (no code needed):

    • Navigate to your Communication Services resource.
    • In the left menu > Email > Try Email.
    • Select a verified sender domain.
    • Enter recipient email, subject, plain text/HTML body.
    • Click Send.

    This is the fastest way to verify setup and send an email, point-and-click in the portal.

    Reference: Send an email using Azure Communication Services (Quickstart)

    Programmatic Sending Approach:

    • Use the Azure.Communication.Email SDK (available in C#, JavaScript, Python, Java, etc.).
    using Azure.Communication.Email;
    using Azure;
    string connectionString = "<your-communication-services-connection-string>";
    var emailClient = new EmailClient(connectionString);
    var emailContent = new EmailContent("Welcome Notification")
    {
        PlainText = "Hello, this is a test email from Azure Communication Services!"
    };
    var emailMessage = new EmailMessage(
        senderAddress: "******@your-verified-domain.azurecomm.net",  // or custom domain
        recipientAddress: "recipient@example.com",
        content: emailContent);
    var response = await emailClient.SendAsync(Azure.WaitUntil.Completed, emailMessage);
    Console.WriteLine($"Email sent! Message ID: {response.Value.MessageId}");
    
    • Install: dotnet add package Azure.Communication.Email
    • Quickstarts (multiple languages): Send an email

    We can also send email using:

    ACS supports SMTP with modern auth (Microsoft Entra ID / OAuth).

    • Host: smtp.azurecomm.net
    • Port: 587 (STARTTLS)
    • Auth: Use an Entra app registration + client secret (or certificate) → create SMTP username in portal.
    • Quickstart: Send an email using SMTP

    Example PowerShell (Send-MailMessage):

    Send-MailMessage -From "******@yourdomain.com" `
                     -To "recipient@example.com" `
                     -Subject "Test" `
                     -Body "Hello from Azure SMTP" `
                     -SmtpServer "smtp.azurecomm.net" `
                     -Port 587 `
                     -UseSsl `
                     -Credential (Get-Credential)  # Entra app credentials
    

    Kindly let us know if the above helps or you need further assistance on this issue.

    Please "upvote" and "accept" if the information helped you. This will help us and others in the community as well.

    0 comments No comments

  2. Marcin Policht 82,760 Reputation points MVP Volunteer Moderator
    2026-02-11T17:51:09.9+00:00

    You can send emails from the Microsoft ecosystem in two main ways depending on what you are building. If you are sending transactional or application-generated emails from a cloud service, Azure is typically used through Azure Communication Services Email or through a partner like SendGrid. If you want to send emails directly from a mailbox such as Outlook or Microsoft 365, you normally use Microsoft Graph API or SMTP with OAuth authentication. The choice depends on whether you need application-level messaging at scale or mailbox-level sending that appears in a user’s Outlook “Sent” folder.

    Using Azure Communication Services Email is the “native Azure” approach for automated notifications, backend systems, and scalable services. You create an Email Communication resource in Azure, verify a domain or use a managed domain, obtain a connection string, and send through SDKs or REST APIs. The application authenticates with a connection string or Entra ID, constructs the email payload, and submits it to the Azure service which handles delivery infrastructure. This approach is best when your application runs in Azure and you do not want to manage SMTP servers.

    from
    
    connection_string
    client
    
    message
        
        
            
        },
        
            
            
        }
    }
    
    poller
    result
    print
    

    You can also use Azure with SendGrid if you want advanced marketing features or an SMTP relay model. Azure Marketplace allows provisioning SendGrid, after which you send via SMTP or API using a SendGrid API key. This is common when migrating from traditional SMTP infrastructure but still wanting Azure billing and deployment integration.

    import
    from
    
    sg
    message
        
        
        
        
    )
    response
    print
    

    Sending through Outlook or Microsoft 365 is usually done with Microsoft Graph API when you want the message to originate from a real mailbox and follow tenant security policies. The process involves registering an application in Microsoft Entra ID, granting Mail.Send permissions, obtaining an OAuth access token, and calling the Graph sendMail endpoint. This method is recommended over basic SMTP authentication because Microsoft is deprecating legacy auth and enforcing modern authentication.

    POST https://graph.microsoft.com/v1.0/users/******@domain.com/sendMail
    Authorization: Bearer ACCESS_TOKEN
    Content-Type: application/json
    
    {
      "message": {
        "subject": "Graph API Email",
        "body": {
          "contentType": "Text",
          "content": "Hello from Microsoft Graph"
        },
        "toRecipients": [
          {
            "emailAddress": {
              "address": "recipient@example.com"
            }
          }
        ]
      }
    }
    

    If you specifically need SMTP through Outlook or Microsoft 365, you configure the SMTP server smtp.office365.com with TLS on port 587 and authenticate using OAuth2 tokens instead of passwords. This is useful for legacy applications that cannot move to REST APIs yet but still need secure authentication tied to an Outlook mailbox.

    import
    from
    
    smtp_server
    port
    msg
    msg
    msg
    msg
    
    with
        
        
        
    

    In practice, Azure Communication Services or SendGrid is better for automated notifications, system alerts, and high-volume transactional emails, while Microsoft Graph or Outlook SMTP is better when emails should be tied to a user mailbox, internal corporate workflows, or compliance logging in Microsoft 365.

    More at https://learn.microsoft.com/en-us/azure/communication-services/concepts/email/email-overview


    If the above response helps answer your question, remember to "Accept Answer" so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.

    hth

    Marcin

    0 comments No comments

Your answer

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