Promact.EmailService
2.0.0
See the version list below for details.
dotnet add package Promact.EmailService --version 2.0.0
NuGet\Install-Package Promact.EmailService -Version 2.0.0
<PackageReference Include="Promact.EmailService" Version="2.0.0" />
<PackageVersion Include="Promact.EmailService" Version="2.0.0" />
<PackageReference Include="Promact.EmailService" />
paket add Promact.EmailService --version 2.0.0
#r "nuget: Promact.EmailService, 2.0.0"
#:package Promact.EmailService@2.0.0
#addin nuget:?package=Promact.EmailService&version=2.0.0
#tool nuget:?package=Promact.EmailService&version=2.0.0
EmailService
Generic Email service implementation for sending emails via different Email providers (SES, SendGrid,SMTP,Azure etc.)
Usage
IEmailService, Email, EmailAddress, AttachmentData, and TemplatedEmailRequest all live in the Promact.EmailService namespace (the core package).
using Promact.EmailService;
private IEmailService _emailService;
public async Task MyMethod()
{
// The email which we are using should be verified in Service Provider whichever you are using (SES, SendGrid,SMTP etc.)
//In Case Of Azure Your EmailDomain Should be Verified And Connected To Your Email Communications Services
var email = new Email(
to: new List<EmailAddress>
{
new EmailAddress("xyz@domain.com", "Receiver Name"),
new EmailAddress("lmn@domain.com", "Receiver Name")
},
from: new EmailAddress("abc@pqr.com", "Sender Name"),
cc: new List<EmailAddress>
{
new EmailAddress("xyz1@domain.com", "Receiver Name"),
new EmailAddress("lmn1@domain.com", "Receiver Name")
},
bcc: new List<EmailAddress>
{
new EmailAddress("xyz2@domain.com", "Receiver Name"),
new EmailAddress("lmn2@domain.com", "Receiver Name")
},
subject: "Test subject",
body: "Test body",
isBodyHtml: true
);
// Add attachments. You can Attach Multiple Attachment
email.Attachments.Add(new AttachmentData(
content: System.IO.File.ReadAllBytes("path/to/file.txt"),
fileName: "FileName",
contentType: "FileType"
));
await _emailService.SendEmailAsync(email);
}
public async Task SendTemplatedEmail()
{
var templatedEmailRequest = new TemplatedEmailRequest(
to: new List<EmailAddress>
{
new EmailAddress("xyz@domain.com", "Receiver Name"),
new EmailAddress("lmn@domain.com", "Receiver Name")
},
from: new EmailAddress("abc@pqr.com", "Sender Name"),
cc: new List<EmailAddress>
{
new EmailAddress("xyz1@domain.com", "Receiver Name"),
new EmailAddress("lmn1@domain.com", "Receiver Name")
},
bcc: new List<EmailAddress>
{
new EmailAddress("xyz2@domain.com", "Receiver Name"),
new EmailAddress("lmn2@domain.com", "Receiver Name")
},
templateNameOrId: "TemplateID", // Replace with your actual template name or ID
templateData: new { name = "Value1" }, // Replace with your actual template data
subject: "Subject"
);
// Add attachments
templatedEmailRequest.Attachments.Add(new AttachmentData(
content: System.IO.File.ReadAllBytes("path/to/file.txt"),
fileName: "FileName",
contentType: "FileType"
));
await _emailService.SendTemplatedEmailAsync(templatedEmailRequest);
}
SES
Add nuget package
Promact.EmailService.SES
ASP.NET Core projects
Add below in Startup.cs inside ConfigureServices method
services.AddSESEmailService(options =>
{
options.AccessKeyId = Configuration.GetSection("AWS:AccessKeyId").Value;
options.SecretAccessKey = Configuration.GetSection("AWS:SecretAccessKey").Value;
options.Region = Configuration.GetSection("AWS:Region").Value;
});
Add relevant appsettings.json values
"AWS": {
"AccessKeyID": "",
"SecretAccessKey": "",
"Region": ""
}
Inject IEmailService in class constructor from where you want to send emails
public MyClass(IEmailService emailService)
{
...
}
Console or other type of applications
Create new object of SESEmailService passing relevant configuration values
var emailService = new SESEmailService(new SESOptions(){ });
SendGrid
Add nuget package
Promact.EmailService.SendGrid
ASP.NET Core projects
Add below in Startup.cs inside ConfigureServices method
services.AddSendGridEmailService(options =>
{
options.APIKey = Configuration.GetSection("SendGrid:APIKey").Value;
});
Add relevant appsettings.json values
"SendGrid": {
"APIKey": ""
}
Inject IEmailService in class constructor from where you want to send emails
public MyClass(IEmailService emailService)
{
...
}
Console or other type of applications
Create new object of SendGridEmailService passing relevant configuration values
var emailService = new SendGridEmailService(new SendGridOptions(){ });
SMTP
Add nuget package
Promact.EmailService.SMTP
ASP.NET Core projects
Add below in Startup.cs inside ConfigureServices method
services.AddSMTPEmailService(options =>
{
options.Host = configuration.GetSection("SMTP:Host").Value;
options.Port = int.Parse(configuration.GetSection("SMTP:Port").Value);
options.UserName = configuration.GetSection("SMTP:UserName").Value;
options.Password = configuration.GetSection("SMTP:Password").Value;
});
Add relevant appsettings.json values
"SMTP": {
"Host": "",
"Port":,
"UserName": "",
"Password": ""
}
Inject IEmailService in class constructor from where you want to send emails
public MyClass(IEmailService emailService)
{
...
}
Console or other type of applications
Create new object of SMTPEmailService passing relevant configuration values
var emailService = new SMTPEmailService(new SMTPOptions(){ });
Azure
Add nuget package
Promact.EmailService.Azure
ASP.NET Core projects
Add below in Startup.cs inside ConfigureServices method
services.AddAzureEmailService(options =>
{
options.ConnectionString= Configuration.GetSection("Azure:ConnectionString").Value;
});
Add relevant appsettings.json values
// You can get your connection string From Azure Portal in Your Communication Service > Setting > Keys.
"Azure": {
"ConnectionString": ""
},
Inject IEmailService in class constructor from where you want to send emails
public MyClass(IEmailService emailService)
{
...
}
Console or other type of applications
Create new object of AzureEmailService passing relevant configuration values
var emailService = new AzureEmailService(new AzureOptions(){ });
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Newtonsoft.Json (>= 13.0.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.0.0 | 91 | 7/25/2026 |
| 2.0.0 | 88 | 7/25/2026 |
| 2.0.0-beta-1.0.0 | 166 | 2/16/2024 |
| 1.0.1 | 1,271 | 10/5/2020 |
| 1.0.0 | 608 | 10/5/2020 |