Devplus.Mail 1.1.0

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

Devplus.Mail ✉️

NuGet Downloads

✉️ Biblioteca para envio de emails utilizando o SendGrid.


🚀 Instalação

Para instalar a biblioteca via NuGet, utilize o seguinte comando:

dotnet add package Devplus.Mail

Ou, no Visual Studio:

  1. Abra o Gerenciador de Pacotes NuGet.
  2. Busque por Devplus.Mail.
  3. Clique em Instalar.

⚡ Como Usar

📤 Enviando Emails

using Devplus.Mail.Interfaces;

public class EmailServiceExample
{
    private readonly IEmailService _emailService;

    public EmailServiceExample(IEmailService emailService)
    {
        _emailService = emailService;
    }

    public async Task SendEmail()
    {
        await _emailService.SendEmailAsync(
            toEmail: "example@domain.com",
            subject: "Bem-vindo ao Devplus!",
            plainTextContent: "Obrigado por se registrar.",
            htmlContent: "<strong>Obrigado por se registrar.</strong>"
        );
    }
}

📋 Enviando Emails com Template

using Devplus.Mail.Enum;
using Devplus.Mail.Interfaces;

public class TemplateEmailExample
{
    private readonly IEmailService _emailService;

    public TemplateEmailExample(IEmailService emailService)
    {
        _emailService = emailService;
    }

    public async Task SendTemplateEmail()
    {
        await _emailService.SendTemplateEmail(
            toEmail: "example@domain.com",
            subject: "Aviso Importante",
            message: "Sua conta foi atualizada com sucesso.",
            link: "https://www.devplus.com.br",
            templateType: EmailTemplateType.Success
        );
    }
}

📎 Enviando Emails com Anexos

using System.Text;
using Devplus.Mail.Interfaces;
using Devplus.Mail.Models;

public class EmailWithAttachmentExample
{
    private readonly IEmailService _emailService;

    public EmailWithAttachmentExample(IEmailService emailService)
    {
        _emailService = emailService;
    }

    public async Task SendEmailWithAttachment()
    {
        var csvContent = "Nome,Email,Idade\nClayton,clayton@devplus.com.br,30\nMaria,maria@devplus.com.br,25";
        var csvBytes = Encoding.UTF8.GetBytes(csvContent);
        var csvAttachment = new EmailAttachment
        {
            FileName = "usuarios.csv",
            MimeType = "text/csv",
            Disposition = "attachment",
            ContentStream = new MemoryStream(csvBytes),
        };

        await _emailService.SendEmailAsync(
            toEmail: "example@domain.com",
            subject: "Relatório de Usuários",
            plainTextContent: "Segue em anexo o relatório de usuários.",
            htmlContent: "<strong>Segue em anexo o relatório de usuários.</strong>",
            attachments: new[] { csvAttachment }
        );
    }
}

🔧 Configuração via appsettings.json

{
  "SendGrid": {
    "ApiKey": "sua-api-key",
    "FromEmail": "noreply@devplus.com.br",
    "FromName": "Devplus"
  }
}

E no Program.cs:

var configuration = new ConfigurationBuilder()
    .AddJsonFile("appsettings.json")
    .Build();

builder.Services.AddMail(configuration);

🛠 Compatibilidade

.NET Version Suportado
.NET 8.0 ✅ Sim
.NET 7.0 ✅ Sim
.NET 6.0 ✅ Sim
.NET Core 3.1 ⚠️ Suporte limitado
.NET Framework ❌ Não suportado

📌 Funcionalidades

✅ Suporte ao SendGrid para envio de emails.
Injeção de dependência via IServiceCollection.
Configuração via appsettings.json.
✅ Compatível com .NET 6, .NET 7 e .NET 8.
✅ Suporte a templates de email embutidos.
✅ Envio de anexos em emails.


🏗 Contribuindo

Se você quiser contribuir para este projeto:

  1. Fork o repositório.
  2. Crie uma branch (git checkout -b feature/nova-feature).
  3. Faça commit das alterações (git commit -m "Add nova feature").
  4. Envie um Pull Request.

📄 Licença

Este projeto está licenciado sob a MIT License.


📞 Contato

📧 Email: clayton@devplus.com.br
🔗 LinkedIn: Clayton Oliveira
🚀 Devplus Consultoria: www.devplus.com.br

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.  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. 
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.1.0 1,288 4/22/2025
1.0.3 203 4/22/2025