Decode.Email.SendGrid
3.0.0
dotnet add package Decode.Email.SendGrid --version 3.0.0
NuGet\Install-Package Decode.Email.SendGrid -Version 3.0.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="Decode.Email.SendGrid" Version="3.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Decode.Email.SendGrid" Version="3.0.0" />
<PackageReference Include="Decode.Email.SendGrid" />
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 Decode.Email.SendGrid --version 3.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Decode.Email.SendGrid, 3.0.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 Decode.Email.SendGrid@3.0.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=Decode.Email.SendGrid&version=3.0.0
#tool nuget:?package=Decode.Email.SendGrid&version=3.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Decode.Email.SendGrid
SendGrid API email provider implementation with template engine, ASM unsubscribe groups, and console dev logger mode for the Decode ecosystem.
🚀 Features
- SendGrid API Integration: Native integration with SendGrid Web API v3 using official SDK.
- ASM Unsubscribe Groups: Out-of-the-box support for SendGrid unsubscribe group IDs configured via options or per-message metadata.
- Console Dev Logger Mode: Set
UseConsoleLogger = truein development to log email payload without consuming API credits. - Template Engine Integration: Full support for HTML template rendering (
#TAG#or{{TAG}}).
📦 Installation
Add the package to your API or Infrastructure project:
dotnet add package Decode.Email.SendGrid
🛠️ Setup
1. Configure Services in Program.cs
// 1. Register SendGrid Email Provider bound to configuration section
builder.Services.AddDecodeSendGridEmail(builder.Configuration.GetSection("SendGridEmailOptions"));
// 2. (Optional) Register Embedded Email Templates from your Application Assembly
builder.Services.AddDecodeEmailEmbeddedTemplates(typeof(Program).Assembly, "MyApp.Domain.EmailTemplates");
2. Add Configuration in appsettings.json
{
"SendGridEmailOptions": {
"ApiKey": "SG.your_sendgrid_api_key",
"DefaultFromEmail": "noreply@mydomain.com",
"DefaultFromName": "My Application",
"UnsubscribeGroupId": 12345,
"UseConsoleLogger": false
}
}
📖 Usage Example
Sending a Templated Email
using Decode.Email.Abstractions.Interfaces;
using Decode.Email.Abstractions.Models;
public class WelcomeHandler(IEmailService emailService)
{
public async Task HandleAsync(string userEmail, string userName)
{
await emailService.SendTemplateAsync(
to: new EmailAddress(userEmail, userName),
subject: "Welcome to Our Platform",
templateName: "WelcomeEmail",
model: new
{
NOME = userName,
CODE = "123456"
}
);
}
}
Overriding Unsubscribe Group ID per Message
EmailMessage message = new()
{
From = new EmailAddress("noreply@mydomain.com"),
To = [new EmailAddress("user@domain.com")],
Subject = "Special Promotion",
BodyHtml = "<h1>Check out our offer!</h1>"
};
// Override default Unsubscribe Group ID for marketing emails
message.ProviderMetadata["UnsubscribeGroupId"] = 99887;
await emailService.SendAsync(message);
📄 License
This project is licensed under the MIT License.
| 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 is compatible. 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 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- Decode.Email.Abstractions (>= 3.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.2)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 8.0.0)
- Microsoft.Extensions.Options.DataAnnotations (>= 8.0.0)
- SendGrid (>= 9.29.3)
-
net8.0
- Decode.Email.Abstractions (>= 3.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.2)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 8.0.0)
- Microsoft.Extensions.Options.DataAnnotations (>= 8.0.0)
- SendGrid (>= 9.29.3)
-
net9.0
- Decode.Email.Abstractions (>= 3.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.2)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 8.0.0)
- Microsoft.Extensions.Options.DataAnnotations (>= 8.0.0)
- SendGrid (>= 9.29.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.