Cakemail.Sdk.Shared 0.1.0-rc2

This is a prerelease version of Cakemail.Sdk.Shared.
dotnet add package Cakemail.Sdk.Shared --version 0.1.0-rc2
                    
NuGet\Install-Package Cakemail.Sdk.Shared -Version 0.1.0-rc2
                    
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="Cakemail.Sdk.Shared" Version="0.1.0-rc2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Cakemail.Sdk.Shared" Version="0.1.0-rc2" />
                    
Directory.Packages.props
<PackageReference Include="Cakemail.Sdk.Shared" />
                    
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 Cakemail.Sdk.Shared --version 0.1.0-rc2
                    
#r "nuget: Cakemail.Sdk.Shared, 0.1.0-rc2"
                    
#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 Cakemail.Sdk.Shared@0.1.0-rc2
                    
#: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=Cakemail.Sdk.Shared&version=0.1.0-rc2&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Cakemail.Sdk.Shared&version=0.1.0-rc2&prerelease
                    
Install as a Cake Tool

Cakemail SDK for .NET

This SDK provides a convenient way to interact with the Cakemail API from your .NET applications.

Installation

You can install the Cakemail SDK via NuGet Package Manager:

Install-Package Cakemail.SDK

Configuration

The SDK relies on configuration settings typically found in your appsettings.json file. Here's an example of the required Cakemail section:

"Cakemail": {
    "Authentication": {
      "TokenEndpoint": "YOUR_CAKEMAIL_TOKEN_ENDPOINT",
      "Username": "YOUR_CAKEMAIL_USERNAME",
      "Password": "YOUR_CAKEMAIL_PASSWORD",
      "Cache": {
        "ExpirationOffset": 15,
        "CacheKey": "CakemailJwtTokenManager.JwtTokenResult"
      }
    }
  }

Important: Replace "YOUR_CAKEMAIL_TOKEN_ENDPOINT", "YOUR_CAKEMAIL_USERNAME", and "YOUR_CAKEMAIL_PASSWORD" with your actual Cakemail API credentials.

Service Configuration

To integrate the Cakemail SDK into your .NET application's dependency injection container, you'll need to configure the services in your Startup.cs or Program.cs file.

services.AddMemoryCache(); // Add to reuse the same Jwt token until it expires
services.AddHttpClient(); // Required for making HTTP requests
services.AddCakemailSdk(); // Adds Cakemail SDK services
  • services.AddMemoryCache(): This is highly recommended to cache the JWT token obtained from Cakemail, preventing repeated authentication requests and improving performance.
  • services.AddHttpClient(): This registers the necessary HttpClient services for the SDK to make API calls.
  • services.AddCakemailSdk(): This extension method registers all the necessary Cakemail SDK services, including various API clients, with your dependency injection container.

Usage

The Cakemail SDK provides various services for interacting with different aspects of the Cakemail API. Here's an example of how to use the TransactionalEmailService to send an email:

public class MyService
{
    private readonly TransactionalEmailService _transactionalEmailService;

    public MyService(TransactionalEmailService transactionalEmailService)
    {
        _transactionalEmailService = transactionalEmailService;
    }

    public async Task SendEmailAsync(string senderId, string recipient, string subject, string message)
    {
        await _transactionalEmailService.SendEmailAsync(new SendEmailOptions
        {
            Email = recipient,
            Sender = new Sender
            {
                Id = senderId
            },
            Content = new EmailContent
            {
                Subject = subject,
                Text = message,
                Encoding = EmailEncoding.Utf8,
            },
            Tracking = new TrackingOptions
            {
                ClicksHtml = false, // Set to true to track clicks on HTML links
                ClicksText = false, // Set to true to track clicks on text links
                Opens = true // Set to true to track email opens
            },
            Queue = 0 // Optional: The queue ID to use for sending the email
        });
    }
}

In this example:

  1. The MyService class injects the TransactionalEmailService.
  2. The SendEmailAsync method demonstrates how to construct a SendEmailOptions object with the recipient, sender, email content (subject, text, encoding), and tracking options.
  3. EmailEncoding.Utf8 is a common encoding for email content.
  4. TrackingOptions allow you to control whether email opens and clicks are tracked.

Available Services

The Cakemail SDK provides dedicated services for different API functionalities. You can inject these services into your classes as needed:

  • TransactionalEmailService: For sending transactional emails.

Resources

License MIT

Product Compatible and additional computed target framework versions.
.NET 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net9.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Cakemail.Sdk.Shared:

Package Downloads
Cakemail.TransactionalEmail

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0-rc2 128 7/15/2025