VOOZH about

URL: https://www.nuget.org/packages/Azure.Communication.Email/

⇱ NuGet Gallery | Azure.Communication.Email 1.1.0




👁 Image
Azure.Communication.Email 1.1.0

Prefix Reserved
dotnet add package Azure.Communication.Email --version 1.1.0
 
 
NuGet\Install-Package Azure.Communication.Email -Version 1.1.0
 
 
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Azure.Communication.Email" Version="1.1.0" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Azure.Communication.Email" Version="1.1.0" />
 
Directory.Packages.props
<PackageReference Include="Azure.Communication.Email" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Azure.Communication.Email --version 1.1.0
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Azure.Communication.Email, 1.1.0"
 
 
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Azure.Communication.Email@1.1.0
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Azure.Communication.Email&version=1.1.0
 
Install as a Cake Addin
#tool nuget:?package=Azure.Communication.Email&version=1.1.0
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Azure Communication Email client library for .NET

This package contains a C# SDK for Azure Communication Services for Email.

Source code | Package (NuGet) | Product documentation

Getting started

Install the package

Install the Azure Communication Email client library for .NET with NuGet:

dotnet add package Azure.Communication.Email

Prerequisites

You need an Azure subscription, a Communication Service Resource, and an Email Communication Resource with an active Domain.

To create these resource, you can use the Azure Portal, the Azure PowerShell, or the .NET management client library.

Key concepts

EmailClient provides the functionality to send email messages .

Using statements

using Azure.Communication.Email;

Authenticate the client

Email clients can be authenticated using the connection string acquired from an Azure Communication Resource in the Azure Portal.

var connectionString = "<connection_string>"; // Find your Communication Services resource in the Azure portal
EmailClient emailClient = new EmailClient(connectionString);

Alternatively, Email clients can also be authenticated using a valid token credential. With this option, AZURE_CLIENT_SECRET, AZURE_CLIENT_ID and AZURE_TENANT_ID environment variables need to be set up for authentication.

string endpoint = "<endpoint_url>";
var tokenCredential = new DefaultAzureCredential();
EmailClient emailClient = new EmailClient(new Uri(endpoint), tokenCredential);

Examples

Send a simple email message with automatic polling for status

To send an email message, call the simple overload of Send or SendAsync function from the EmailClient.

try
{
 var emailSendOperation = emailClient.Send(
 wait: WaitUntil.Completed,
 senderAddress: "<Send email address>" // The email address of the domain registered with the Communication Services resource
 recipientAddress: "<recipient email address>"
 subject: "This is the subject",
 htmlContent: "<html><body>This is the html body</body></html>");
 Console.WriteLine($"Email Sent. Status = {emailSendOperation.Value.Status}");

 /// Get the OperationId so that it can be used for tracking the message for troubleshooting
 string operationId = emailSendOperation.Id;
 Console.WriteLine($"Email operation id = {operationId}");
}
catch ( RequestFailedException ex )
{
 /// OperationID is contained in the exception message and can be used for troubleshooting purposes
 Console.WriteLine($"Email send operation failed with error code: {ex.ErrorCode}, message: {ex.Message}");
}

Send a simple email message with manual polling for status

To send an email message, call the simple overload of Send or SendAsync function from the EmailClient.

/// Send the email message with WaitUntil.Started
var emailSendOperation = await emailClient.SendAsync(
 wait: WaitUntil.Started,
 senderAddress: "<Send email address>" // The email address of the domain registered with the Communication Services resource
 recipientAddress: "<recipient email address>"
 subject: "This is the subject",
 htmlContent: "<html><body>This is the html body</body></html>");

/// Call UpdateStatus on the email send operation to poll for the status
/// manually.
try
{
 while (true)
 {
 await emailSendOperation.UpdateStatusAsync();
 if (emailSendOperation.HasCompleted)
 {
 break;
 }
 await Task.Delay(100);
 }

 if (emailSendOperation.HasValue)
 {
 Console.WriteLine($"Email queued for delivery. Status = {emailSendOperation.Value.Status}");
 }
}
catch (RequestFailedException ex)
{
 Console.WriteLine($"Email send failed with Code = {ex.ErrorCode} and Message = {ex.Message}");
}

/// Get the OperationId so that it can be used for tracking the message for troubleshooting
string operationId = emailSendOperation.Id;
Console.WriteLine($"Email operation id = {operationId}");

Send an email message with more options

To send an email message, call the overload of Send or SendAsync function from the EmailClient that takes an EmailMessage parameter.

// Create the email content
var emailContent = new EmailContent("This is the subject")
{
 PlainText = "This is the body",
 Html = "<html><body>This is the html body</body></html>"
};

// Create the EmailMessage
var emailMessage = new EmailMessage(
 senderAddress: "<Send email address>" // The email address of the domain registered with the Communication Services resource
 recipientAddress: "<recipient email address>"
 content: emailContent);

try
{
 var emailSendOperation = emailClient.Send(
 wait: WaitUntil.Completed,
 message: emailMessage);
 Console.WriteLine($"Email Sent. Status = {emailSendOperation.Value.Status}");

 /// Get the OperationId so that it can be used for tracking the message for troubleshooting
 string operationId = emailSendOperation.Id;
 Console.WriteLine($"Email operation id = {operationId}");
}
catch ( RequestFailedException ex )
{
 /// OperationID is contained in the exception message and can be used for troubleshooting purposes
 Console.WriteLine($"Email send operation failed with error code: {ex.ErrorCode}, message: {ex.Message}");
}

Send an email message to multiple recipients

To send an email message to multiple recipients, add an EmailAddress object for each recipent type to the EmailRecipient object.

// Create the email content
var emailContent = new EmailContent("This is the subject")
{
 PlainText = "This is the body",
 Html = "<html><body>This is the html body</body></html>"
};

// Create the To list
var toRecipients = new List<EmailAddress>
{
 new EmailAddress(
 address: "<recipient email address>"
 displayName: "<recipient displayname>"
 new EmailAddress(
 address: "<recipient email address>"
 displayName: "<recipient displayname>"
};

// Create the CC list
var ccRecipients = new List<EmailAddress>
{
 new EmailAddress(
 address: "<recipient email address>"
 displayName: "<recipient displayname>"
 new EmailAddress(
 address: "<recipient email address>"
 displayName: "<recipient displayname>"
};

// Create the BCC list
var bccRecipients = new List<EmailAddress>
{
 new EmailAddress(
 address: "<recipient email address>"
 displayName: "<recipient displayname>"
 new EmailAddress(
 address: "<recipient email address>"
 displayName: "<recipient displayname>"
};

var emailRecipients = new EmailRecipients(toRecipients, ccRecipients, bccRecipients);

// Create the EmailMessage
var emailMessage = new EmailMessage(
 senderAddress: "<Send email address>" // The email address of the domain registered with the Communication Services resource
 emailRecipients,
 emailContent);

try
{
 EmailSendOperation emailSendOperation = emailClient.Send(WaitUntil.Completed, emailMessage);
 Console.WriteLine($"Email Sent. Status = {emailSendOperation.Value.Status}");

 /// Get the OperationId so that it can be used for tracking the message for troubleshooting
 string operationId = emailSendOperation.Id;
 Console.WriteLine($"Email operation id = {operationId}");
}
catch ( RequestFailedException ex )
{
 /// OperationID is contained in the exception message and can be used for troubleshooting purposes
 Console.WriteLine($"Email send operation failed with error code: {ex.ErrorCode}, message: {ex.Message}");
}

Send email with attachments

Azure Communication Services support sending emails with attachments.

// Create the EmailMessage
var emailMessage = new EmailMessage(
 senderAddress: "<Send email address>" // The email address of the domain registered with the Communication Services resource
 recipientAddress: "<recipient email address>"
 content: emailContent);

var filePath = "<path to your file>";
var attachmentName = "<name of your attachment>";
var contentType = MediaTypeNames.Text.Plain;

var content = new BinaryData(System.IO.File.ReadAllBytes(filePath));
var emailAttachment = new EmailAttachment(attachmentName, contentType, content);

emailMessage.Attachments.Add(emailAttachment);

try
{
 EmailSendOperation emailSendOperation = emailClient.Send(WaitUntil.Completed, emailMessage);
 Console.WriteLine($"Email Sent. Status = {emailSendOperation.Value.Status}");

 /// Get the OperationId so that it can be used for tracking the message for troubleshooting
 string operationId = emailSendOperation.Id;
 Console.WriteLine($"Email operation id = {operationId}");
}
catch ( RequestFailedException ex )
{
 /// OperationID is contained in the exception message and can be used for troubleshooting purposes
 Console.WriteLine($"Email send operation failed with error code: {ex.ErrorCode}, message: {ex.Message}");
}

Send email with inline attachments

Azure Communication Services support sending inline attachments. Adding an optional contentId parameter to the EmailAttachment constructor will make the attachment an inline attachment.

// Create the email content and reference any inline attachments.
var emailContent = new EmailContent("This is the subject")
{
 PlainText = "This is the body",
 Html = "<html><body>This is the html body<img src=\"cid:myInlineAttachmentContentId\"></body></html>"
};

// Create the EmailMessage
var emailMessage = new EmailMessage(
 senderAddress: "<Send email address>" // The email address of the domain registered with the Communication Services resource
 recipientAddress: "<recipient email address>"
 content: emailContent);

var filePath = "<path to your file>";
var attachmentName = "<name of your attachment>";
var contentType = MediaTypeNames.Text.Plain;
var contentId = "myInlineAttachmentContentId";

var content = new BinaryData(System.IO.File.ReadAllBytes(filePath));
var emailAttachment = new EmailAttachment(attachmentName, contentType, content);
emailAttachment.ContentId = contentId;

emailMessage.Attachments.Add(emailAttachment);

try
{
 EmailSendOperation emailSendOperation = emailClient.Send(WaitUntil.Completed, emailMessage);
 Console.WriteLine($"Email Sent. Status = {emailSendOperation.Value.Status}");

 /// Get the OperationId so that it can be used for tracking the message for troubleshooting
 string operationId = emailSendOperation.Id;
 Console.WriteLine($"Email operation id = {operationId}");
}
catch ( RequestFailedException ex )
{
 /// OperationID is contained in the exception message and can be used for troubleshooting purposes
 Console.WriteLine($"Email send operation failed with error code: {ex.ErrorCode}, message: {ex.Message}");
}

Troubleshooting

A RequestFailedException is thrown as a service response for any unsuccessful requests. The exception contains information about what response code was returned from the service.

Next steps

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit cla.microsoft.com.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact with any additional questions or comments.

Product Versions Compatible and additional computed target framework versions.
.NET net5.0 net5.0 was computed.  net5.0-windows net5.0-windows was computed.  net6.0 net6.0 was computed.  net6.0-android net6.0-android was computed.  net6.0-ios net6.0-ios was computed.  net6.0-maccatalyst net6.0-maccatalyst was computed.  net6.0-macos net6.0-macos was computed.  net6.0-tvos net6.0-tvos was computed.  net6.0-windows net6.0-windows was computed.  net7.0 net7.0 was computed.  net7.0-android net7.0-android was computed.  net7.0-ios net7.0-ios was computed.  net7.0-maccatalyst net7.0-maccatalyst was computed.  net7.0-macos net7.0-macos was computed.  net7.0-tvos net7.0-tvos was computed.  net7.0-windows net7.0-windows was computed.  net8.0 net8.0 is compatible.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 was computed.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 was computed.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
.NET Core netcoreapp2.0 netcoreapp2.0 was computed.  netcoreapp2.1 netcoreapp2.1 was computed.  netcoreapp2.2 netcoreapp2.2 was computed.  netcoreapp3.0 netcoreapp3.0 was computed.  netcoreapp3.1 netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 netstandard2.0 is compatible.  netstandard2.1 netstandard2.1 was computed. 
.NET Framework net461 net461 was computed.  net462 net462 was computed.  net463 net463 was computed.  net47 net47 was computed.  net471 net471 was computed.  net472 net472 was computed.  net48 net48 was computed.  net481 net481 was computed. 
MonoAndroid monoandroid monoandroid was computed. 
MonoMac monomac monomac was computed. 
MonoTouch monotouch monotouch was computed. 
Tizen tizen40 tizen40 was computed.  tizen60 tizen60 was computed. 
Xamarin.iOS xamarinios xamarinios was computed. 
Xamarin.Mac xamarinmac xamarinmac was computed. 
Xamarin.TVOS xamarintvos xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (63)

Showing the top 5 NuGet packages that depend on Azure.Communication.Email:

Package Downloads
Indice.Services

Package Description

OrchardCore.Application.Cms.Core.Targets

Orchard Core CMS is a Web Content Management System (CMS) built on top of the Orchard Core Framework. Converts the application into a modular OrchardCore CMS application with TheAdmin theme but without any front-end Themes.

OrchardCore.Application.Cms.Targets

Orchard Core CMS is a Web Content Management System (CMS) built on top of the Orchard Core Framework. Converts the application into a modular OrchardCore CMS application with following themes. - TheAdmin Theme - SafeMode Theme - TheAgency Theme - TheBlog Theme - TheComingSoon Theme - TheTheme theme

WATG.Common

WATG library of commonly used and shared functionalities

FonsecaFramework.Azure

Azure Connection Library

GitHub repositories (6)

Showing the top 6 popular GitHub repositories that depend on Azure.Communication.Email:

Repository Stars
OrchardCMS/OrchardCore
Orchard Core is an open-source modular and multi-tenant application framework built with ASP.NET Core, and a content management system (CMS) built on top of that framework.
microsoft/mcp
Catalog of official Microsoft MCP (Model Context Protocol) server implementations for AI-powered data access and tool integration
VedAstro/VedAstro
A non-profit, open source project to make Vedic Astrology easily available to all.
platformplatform/PlatformPlatform
A platform designed for building enterprise-grade, multi-tenant products using Azure, .NET, React, TypeScript, Infrastructure as Code, etc.
Azure-Samples/communication-services-AI-customer-service-sample
A sample app for the customer support center running in Azure, using Azure Communication Services and Azure OpenAI for text and voice bots.
Azure-Samples/communication-services-dotnet-quickstarts
Sample code for Azure Communication Services .Net quickstarts
Version Downloads Last Updated
1.1.0 2,676,733 10/7/2025
1.1.0-beta.2 138,756 9/26/2024
1.1.0-beta.1 48,716 7/11/2024
1.0.2 275,495 9/19/2025
1.0.1 7,812,338 8/18/2023
1.0.0 560,692 3/31/2023
1.0.0-beta.4 43,330 3/16/2023
1.0.0-beta.3 2,155 3/14/2023
1.0.0-beta.2 9,946 3/7/2023
1.0.0-beta.1 401,775 5/24/2022