PandaTech.MailHelper 1.0.7

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

// Install PandaTech.MailHelper as a Cake Tool
#tool nuget:?package=PandaTech.MailHelper&version=1.0.7                

PandaTech.MailHelper NuGet

Introduction

PandaTech.MailHelper is a .NET library that simplifies sending emails using the System.Net.Mail namespace. It provides a simple interface for sending emails asynchronously, with support for attachments.

Installation

The library can be installed via NuGet Package Manager or by adding a reference to the PandaTech.MailHelper package in your project.

Usage

Configuration

The MailServerConfig class is used to configure the SMTP server details:

public class MailServerConfig
{
    public string SmtpServer { get; set; } = null!;
    public int SmtpPort { get; set; }
    public string SmtpUser { get; set; } = null!;
    public string SmtpPassword { get; set; } = null!;
    public string SmtpFrom { get; set; } = null!;
}

To use PandaTech.MailHelper, create an instance of MailSender by passing a MailServerConfig instance to its constructor:

var mailConfig = new MailServerConfig
{
    SmtpServer = "smtp.gmail.com",
    SmtpPort = 587,
    SmtpUser = "your_email@gmail.com",
    SmtpPassword = "your_password",
    SmtpFrom = "your_email@gmail.com",
};

var mailSender = new MailSender(mailConfig, logger);

Sending Emails

mailSender.SendMail("recipient@example.com", "Subject", "Body");

To include attachments, pass an optional List<AttachmentData> parameter to the SendMail method:

var attachment = new AttachmentData
{
    Name = "attachment.txt",
    Data = File.ReadAllBytes("path/to/attachment.txt"),
};
var attachments = new List<AttachmentData> { attachment };

mailSender.SendMail("recipient@example.com", "Subject", "Body", attachments);

Credits

PandaTech.MailHelper was created by <u>PandaTech Ltd</u> and is licensed under the <u>MIT license</u>.

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  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. 
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.7 200 4/25/2023
1.0.5 318 4/5/2023
1.0.4 195 4/5/2023