CovenirBPO.Packages.SendgridNotificationSystem 1.1.0

dotnet add package CovenirBPO.Packages.SendgridNotificationSystem --version 1.1.0                
NuGet\Install-Package CovenirBPO.Packages.SendgridNotificationSystem -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="CovenirBPO.Packages.SendgridNotificationSystem" Version="1.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CovenirBPO.Packages.SendgridNotificationSystem --version 1.1.0                
#r "nuget: CovenirBPO.Packages.SendgridNotificationSystem, 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.
// Install CovenirBPO.Packages.SendgridNotificationSystem as a Cake Addin
#addin nuget:?package=CovenirBPO.Packages.SendgridNotificationSystem&version=1.1.0

// Install CovenirBPO.Packages.SendgridNotificationSystem as a Cake Tool
#tool nuget:?package=CovenirBPO.Packages.SendgridNotificationSystem&version=1.1.0                

Sendgrid Notification Library

For Covenir Integration

2024-01-23 Updated: 2024-05-01

Install the library

Install Nuget package CovenirBPO.Packages.SendgridNotificationSystem

Createing a native IEmailNotificationContent object

In your project solution, create an object that inherits the IEmailNotificationContent interface.

This object will contain the required properties that the notification system will utilize when sending notification emails.

using SendgridNotificationSystem.Lib;

namespace SendgridNotificationSystem.Testing;

internal class EmailNotificationContent : IEmailNotificationContent
{
    public List<string> RecipientAddresses { get; set; } = new List<string>();
    public string Subject { get; set; } = string.Empty; 
    public string BodyContent { get; set; } = string.Empty;

    public void AddRecipientAddress(string recipientAddress)
    {
        RecipientAddresses.Add(recipientAddress);
    }

    public void RemoveRecipientAddress(string recipientAddress)
    {
        for (int i = 0; i < RecipientAddresses.Count; i++)
        {
            if (RecipientAddresses[i]== recipientAddress)
            {
                RecipientAddresses.RemoveAt(i);
                break; 
            }   
        }
    }
}

Set an environment variable

Create a local environment variable on the machine that will be sending notifications:

Key Value
SENDGRID_API Your Sendgrid API key

Add Recipients

In the calling assembly, create a new EmailNotificationContent object.

var content = new EmailNotificationContent
{
	Subject = "Subject of Email",
	BodyContent = "Body of the email"
    TemplateID = "Your Sendgrid Template ID" // Optional for text only emails, required for template-based emails
};

content.AddRecipientAddress("receiver@email.com");

Call the service

using SendgridNotificationSystem; 

. . .
// This will produce a basic text-only email. 
public async Task SendEmail(IEmailNotificationContent content)
{
    await new Lib.SendgridNotificationSystem()
        .SendSendgridEmailAsync(content);
}

. . .
 or
. . .
// This will allow dynamically fill the custom template with the same Email notification content
public async Task SendEmailWithTemplate(IEmailNotificationContent content)
{
	await new Lib.SendgridNotificationSystem()
		.SendSendgridTemplateEmailAsync(content);
})
Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on CovenirBPO.Packages.SendgridNotificationSystem:

Package Downloads
CovenirBPO.Packages.PreprocessorCommon

A common core library for Covenir's preprocessor workflow.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.0 390 5/1/2024
1.0.1 223 1/24/2024
1.0.0 103 1/23/2024

BREAKING CHANGE: Added Template ID to IEmailNotificationContent to support the new SendSendgridTemplateEmailAsync method.
NOTE: This will require changes to any existing implementations of IEmailNotificationContent.
NOTE: The IEmailNotificationContent object can be passed to both standard text-based email methods and the new template-based email method.
The template-based email method will pull fields from the IEmailNotificationContent object and populate the template with the values.
Added additional documentation.