Dinocollab.EmailTemplate.Sdk 1.0.0

This package has a SemVer 2.0.0 package version: 1.0.0+first-release.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Dinocollab.EmailTemplate.Sdk --version 1.0.0
                    
NuGet\Install-Package Dinocollab.EmailTemplate.Sdk -Version 1.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="Dinocollab.EmailTemplate.Sdk" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Dinocollab.EmailTemplate.Sdk" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Dinocollab.EmailTemplate.Sdk" />
                    
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 Dinocollab.EmailTemplate.Sdk --version 1.0.0
                    
#r "nuget: Dinocollab.EmailTemplate.Sdk, 1.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 Dinocollab.EmailTemplate.Sdk@1.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=Dinocollab.EmailTemplate.Sdk&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Dinocollab.EmailTemplate.Sdk&version=1.0.0
                    
Install as a Cake Tool

Dinocollab Email Template SDK

A .NET SDK for interacting with Dinocollab Email Template Sender API.

Features

  • Send simple emails without templates
  • Send emails using templates by code
  • Queue emails for background processing
  • Schedule emails for future delivery
  • Send bulk emails
  • Monitor job status
  • Manage placeholders
  • Built-in error handling and retry mechanisms
  • Support for dependency injection

Installation

Add the NuGet package to your project:

dotnet add package Dinocollab.EmailTemplate.Sdk

Quick Start

Basic Usage

using Dinocollab.EmailTemplate.Sdk;
using Dinocollab.EmailTemplate.Sdk.Models;

// Create SDK client
var client = EmailTemplateSdk.CreateClient(
    baseUrl: "https://your-api-endpoint.com",
    apiKey: "your-api-key"
);

// Send a simple email
var simpleEmailRequest = new SendSimpleEmailRequest
{
    To = "recipient@example.com",
    Subject = "Test Email",
    HtmlContent = "<h1>Hello World!</h1>",
    TextContent = "Hello World!",
    SenderAccountCode = "default-sender"
};

var result = await client.Email.SendSimpleEmailAsync(simpleEmailRequest);

Using Builder Pattern

var client = EmailTemplateSdk.CreateBuilder()
    .WithBaseUrl("https://your-api-endpoint.com")
    .WithApiKey("your-api-key")
    .WithDefaultSenderAccountCode("default-sender")
    .WithTimeout(60)
    .Build();

Dependency Injection

// In Program.cs or Startup.cs
services.AddEmailTemplateSdk(options =>
{
    options.BaseUrl = "https://your-api-endpoint.com";
    options.ApiKey = "your-api-key";
    options.DefaultSenderAccountCode = "default-sender";
    options.TimeoutSeconds = 60;
});

// In your controller or service
public class EmailService
{
    private readonly IEmailTemplateSdkClient _emailClient;

    public EmailService(IEmailTemplateSdkClient emailClient)
    {
        _emailClient = emailClient;
    }

    public async Task SendWelcomeEmail(string email, string name)
    {
        var request = new SendTemplateEmailByCodeRequest
        {
            To = email,
            TemplateCode = "welcome-email",
            Placeholders = new Dictionary<string, string>
            {
                ["name"] = name,
                ["date"] = DateTime.Now.ToString("yyyy-MM-dd")
            }
        };

        var result = await _emailClient.Email.SendTemplateEmailByCodeAsync(request);
    }
}

Email Operations

Send Template Email

var templateRequest = new SendTemplateEmailByCodeRequest
{
    To = "recipient@example.com",
    TemplateCode = "welcome-template",
    Placeholders = new Dictionary<string, string>
    {
        ["name"] = "John Doe",
        ["company"] = "Acme Corp"
    },
    SenderAccountCode = "welcome-sender"
};

var result = await client.Email.SendTemplateEmailByCodeAsync(templateRequest);

Queue Email for Background Processing

var queueRequest = new SendSimpleEmailRequest
{
    To = "recipient@example.com",
    Subject = "Queued Email",
    HtmlContent = "<p>This email was queued for processing.</p>"
};

var result = await client.Email.QueueSimpleEmailAsync(queueRequest);
Console.WriteLine($"Job ID: {result.JobId}");

Schedule Email

var scheduleRequest = new ScheduleTemplateEmailRequest
{
    To = "recipient@example.com",
    TemplateCode = "reminder-template",
    ScheduledTime = DateTime.UtcNow.AddHours(24),
    Placeholders = new Dictionary<string, string>
    {
        ["event"] = "Meeting Tomorrow"
    }
};

var result = await client.Email.ScheduleTemplateEmailAsync(scheduleRequest);

Send Bulk Emails

var bulkRequest = new BulkTemplateEmailRequest
{
    TemplateCode = "newsletter",
    DefaultPlaceholders = new Dictionary<string, string>
    {
        ["newsletter_date"] = DateTime.Now.ToString("MMMM yyyy")
    },
    Recipients = new List<BulkEmailRecipient>
    {
        new BulkEmailRecipient
        {
            Email = "user1@example.com",
            Placeholders = new Dictionary<string, string> { ["name"] = "User 1" }
        },
        new BulkEmailRecipient
        {
            Email = "user2@example.com",
            Placeholders = new Dictionary<string, string> { ["name"] = "User 2" }
        }
    }
};

var result = await client.Email.BulkTemplateEmailAsync(bulkRequest);

Monitor Job Status

var jobStatus = await client.Email.GetJobStatusAsync("job-id-here");
Console.WriteLine($"Job State: {jobStatus.State}");
Console.WriteLine($"Created At: {jobStatus.CreatedAt}");

Placeholder Operations

Get All Placeholders

var placeholders = await client.Placeholder.GetPlaceholdersAsync();
foreach (var placeholder in placeholders)
{
    Console.WriteLine($"{placeholder.Key}: {placeholder.Description}");
}

Get Placeholders by Category

var userPlaceholders = await client.Placeholder.GetPlaceholdersByCategoryAsync("user");

Get Specific Placeholder

var placeholder = await client.Placeholder.GetPlaceholderAsync("user.name");
if (placeholder != null)
{
    Console.WriteLine($"Description: {placeholder.Description}");
    Console.WriteLine($"Default Value: {placeholder.DefaultValue}");
}

Error Handling

The SDK provides specific exception types for different error scenarios:

try
{
    var result = await client.Email.SendSimpleEmailAsync(request);
}
catch (AuthenticationException ex)
{
    // Handle authentication errors (401)
    Console.WriteLine($"Authentication failed: {ex.Message}");
}
catch (ValidationException ex)
{
    // Handle validation errors (400)
    Console.WriteLine($"Validation failed: {ex.Message}");
}
catch (ApiRequestException ex)
{
    // Handle other API errors
    Console.WriteLine($"API error ({ex.StatusCode}): {ex.Message}");
}
catch (EmailTemplateSdkException ex)
{
    // Handle general SDK errors
    Console.WriteLine($"SDK error: {ex.Message}");
}

Configuration Options

public class EmailTemplateSdkOptions
{
    public string BaseUrl { get; set; } = "";
    public string ApiKey { get; set; } = "";
    public int TimeoutSeconds { get; set; } = 30;
    public int MaxRetryAttempts { get; set; } = 3;
    public string? DefaultSenderAccountCode { get; set; }
}

API Endpoints

The SDK interacts with the following API endpoints:

  • POST /api/EmailApi/send-simple - Send simple email
  • POST /api/EmailApi/send-template-by-code - Send template email
  • POST /api/EmailApi/queue-simple - Queue simple email
  • POST /api/EmailApi/schedule-template - Schedule template email
  • POST /api/EmailApi/bulk-template - Send bulk emails
  • GET /api/EmailApi/job-status/{jobId} - Get job status
  • GET /api/PlaceholderApi - Get all placeholders
  • GET /api/PlaceholderApi/category/{category} - Get placeholders by category
  • GET /api/PlaceholderApi/{key} - Get specific placeholder

Requirements

  • .NET Standard 2.0 or higher
  • Valid API key for the Email Template Sender service

License

[Add your license information here]

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

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
1.0.1 106 7/4/2025
1.0.0 36 7/3/2025