PandaTech.MailHelper
1.0.7
dotnet add package PandaTech.MailHelper --version 1.0.7
NuGet\Install-Package PandaTech.MailHelper -Version 1.0.7
<PackageReference Include="PandaTech.MailHelper" Version="1.0.7" />
paket add PandaTech.MailHelper --version 1.0.7
#r "nuget: PandaTech.MailHelper, 1.0.7"
// 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 | Versions 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. |
-
net7.0
- Microsoft.Extensions.Hosting (>= 7.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.