Cayaqui.MPS.Email 0.1.1

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

Cayaqui.MPS.Email

Servicio genérico de Email para .NET 10 con proveedores intercambiables + renderer de templates:

  • Azure Communication Services (ACS) — recomendado para stacks Azure-native.
  • SMTP (vía MailKit) — útil para Exchange Online, MailHog/Papercut en dev, corporativos.
  • Templates Scriban cargados desde IStorageService (convención <key>.subject.txt + <key>.html + <key>.text opcional).
  • Inlining CSS automático con PreMailer.Net (compatibilidad Outlook/Gmail).

Distribución propietaria — requiere contrato comercial con Cayaqui. Ver LICENSE.txt.

Dependencia: este paquete requiere Cayaqui.MPS.Storage registrado (AddMpsStorage(...)) para cargar los templates.

Instalación

dotnet add package Cayaqui.MPS.Email
dotnet add package Cayaqui.MPS.Storage

Registro

// ACS con connection string
builder.Services.AddMpsStorage(opt => opt.UseAzureBlob(Configuration["Storage:ConnString"]));
builder.Services.AddMpsEmail(opt =>
    opt.UseAzureCommunicationServices(
        connectionString: Configuration["Acs:ConnString"]!,
        defaultSender:    new EmailAddress("no-reply@cayaqui.com", "MPS")));

// SMTP (Exchange Online / O365)
builder.Services.AddMpsEmail(opt =>
{
    opt.DefaultFrom = new EmailAddress("no-reply@cayaqui.com", "MPS");
    opt.UseSmtp("smtp.office365.com", 587, user, pass, useSsl: true);
});

Uso directo

public class NotificationService(IEmailService email)
{
    public Task NotifyAsync(string userEmail)
        => email.SendAsync(new EmailMessage
        {
            Subject = "Tu reporte está listo",
            HtmlBody = "<p>Hola, tu reporte semanal está adjunto.</p>"
        }.AddTo(new EmailAddress(userEmail)));
}

Uso con templates

  1. Subir los templates al container (default email-templates):
email-templates/welcome.subject.txt    → "Bienvenido, {{ user.name }}"
email-templates/welcome.html           → "<h1>Hola {{ user.name }}</h1>..."
email-templates/welcome.text           → "Hola {{ user.name }}..."   (opcional)
  1. Enviar:
await email.SendTemplateAsync(
    templateKey: "welcome",
    dataContext: new { user = new { name = "Ana" } },
    message:     new EmailMessage().AddTo("ana@example.com"));

Sintaxis Scriban: {{ user.name }}, {{ for item in items }}...{{ end }}, filtros | upcase, | date.to_string "dd MMM yy", etc.

Nota sobre colecciones: para iteración con {{ for ... }} funciona mejor pasar colecciones como Dictionary<string, object>[] o IDictionary<string, object>[] (Scriban maneja diccionarios nativamente). Anonymous types y POCOs anidados pueden requerir ajustar MemberRenamer/MemberFilter.

Requisitos

  • .NET 10.0 o superior
  • Cayaqui.MPS.Storage registrado (para templates)
  • Cuenta Azure Communication Services (si se usa ACS) o servidor SMTP accesible
Product Compatible and additional computed target framework versions.
.NET 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.

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
0.1.1 412 4/24/2026
0.1.0 100 4/24/2026

Initial release. IEmailService with Azure Communication Services and SMTP providers, Scriban templates, PreMailer CSS inlining.