Edi.TemplateEmail
2024.2.1
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Edi.TemplateEmail --version 2024.2.1
NuGet\Install-Package Edi.TemplateEmail -Version 2024.2.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="Edi.TemplateEmail" Version="2024.2.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Edi.TemplateEmail --version 2024.2.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Edi.TemplateEmail, 2024.2.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.
// Install Edi.TemplateEmail as a Cake Addin #addin nuget:?package=Edi.TemplateEmail&version=2024.2.1 // Install Edi.TemplateEmail as a Cake Tool #tool nuget:?package=Edi.TemplateEmail&version=2024.2.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Edi.TemplateEmail
This library enable you to configure email in XML template and send the email in your .NET Core applications.
Install
dotnet add package Edi.TemplateEmail
Usage
Step 1: Put a mailConfiguration.xml somewhere you like
<?xml version="1.0"?>
<MailConfiguration>
<CommonConfiguration OverrideToAddress="false" ToAddress="overridetest@test.com" />
<MailMessage MessageType="TestMail" IsHtml="true">
<MessageSubject>Test Mail on {MachineName.Value}</MessageSubject>
<MessageBody>
<![CDATA[
Mail configuration on {MachineName.Value} is good: <br />
Smtp Server: {SmtpServer.Value}<br />
Smtp Port: {SmtpServerPort.Value}<br />
Smtp Username: {SmtpUserName.Value}<br />
Email Display Name: {EmailDisplayName.Value}<br />
Enable SSL: {EnableSsl.Value}<br />
]]>
</MessageBody>
</MailMessage>
</MailConfiguration>
Step 2:
Initialize the EmailHelper
by your mail server settings
// Change these values
var smtpServer = "smtp-mail.outlook.com";
var userName = "Edi.Test@outlook.com";
var password = "";
var port = 587;
var toAddress = "Edi.Wang@outlook.com";
var configSource = $"{Directory.GetCurrentDirectory()}\\mailConfiguration.xml";
var emailHelper = new EmailHelper(configSource, smtpServer, userName, password, port)
.WithTls()
.WithSenderName("Test Sender")
.WithDisplayName("Edi.TemplateEmail.TestConsole");
You can also add event handlers
emailHelper.EmailSent += (sender, eventArgs) =>
{
Console.WriteLine($"Email is sent, Success: {eventArgs.IsSuccess}, Response: {eventArgs.ServerResponse}");
};
emailHelper.EmailFailed += (sender, eventArgs) => Console.WriteLine("Failed");
emailHelper.EmailCompleted += (sender, e) => Console.WriteLine("Completed.");
Step 3: Map the values and send Email
await emailHelper.ForType("TestMail")
.Map("MachineName", Environment.MachineName)
.Map("SmtpServer", emailHelper.Settings.SmtpServer)
.Map("SmtpServerPort", emailHelper.Settings.SmtpServerPort)
.Map("SmtpUserName", emailHelper.Settings.SmtpUserName)
.Map("EmailDisplayName", emailHelper.Settings.EmailDisplayName)
.Map("EnableTls", emailHelper.Settings.EnableTls)
.SendAsync(toAddress);
免责申明
此项目(Edi.TemplateEmail)及其配套组件均为免费开源的产品,仅用于学习交流,并且不直接向中国提供服务,中国用户请于下载后立即删除。
任何中国境内的组织及个人不得使用此项目(Edi.TemplateEmail)及其配套组件构建任何形式的面向中国境内用户的网站或服务。
不可用于任何违反中华人民共和国(含台湾省)或使用者所在地区法律法规的用途。
因为作者即本人仅完成代码的开发和开源活动(开源即任何人都可以下载使用),从未参与用户的任何运营和盈利活动。
且不知晓用户后续将程序源代码用于何种用途,故用户使用过程中所带来的任何法律责任即由用户自己承担。
Product | Versions 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- MailKit (>= 4.8.0)
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 |
---|---|---|
2024.6.0 | 82 | 11/13/2024 |
2024.5.0 | 130 | 10/11/2024 |
2024.4.0 | 91 | 10/10/2024 |
2024.3.0 | 93 | 10/10/2024 |
2024.2.1 | 87 | 10/8/2024 |
2024.2.0 | 151 | 8/7/2024 |
2024.1.0 | 371 | 5/18/2024 |
2023.4.3 | 136 | 4/15/2024 |
2023.4.2 | 580 | 3/4/2024 |
2023.4.1 | 2,921 | 11/13/2023 |
2023.4.0 | 957 | 10/11/2023 |
2023.3.0 | 161 | 9/5/2023 |
2023.2.2 | 194 | 6/19/2023 |
2023.2.1 | 155 | 6/11/2023 |
2023.2.0 | 194 | 4/29/2023 |
2023.1.1 | 250 | 3/15/2023 |
2023.1.0 | 284 | 2/17/2023 |
2022.5.1 | 352 | 12/2/2022 |
2022.5.0 | 342 | 11/9/2022 |
2022.4.4 | 390 | 10/27/2022 |
2022.4.3 | 806 | 9/13/2022 |
2022.4.2 | 552 | 9/7/2022 |
2022.4.1 | 452 | 8/6/2022 |
2022.4.0 | 456 | 6/20/2022 |
2022.3.0 | 509 | 4/15/2022 |
2022.2.1 | 478 | 4/15/2022 |
2022.2.0 | 461 | 4/15/2022 |
2022.1.0 | 476 | 2/9/2022 |
2021.2.0 | 452 | 10/21/2021 |
2021.1.2 | 2,170 | 5/18/2021 |
2021.1.1 | 380 | 4/22/2021 |
2021.1.0 | 446 | 1/27/2021 |
2020.3.1 | 507 | 11/27/2020 |
2020.3.0 | 481 | 11/11/2020 |
2020.2.4 | 512 | 9/15/2020 |
2020.2.3 | 570 | 7/15/2020 |
2020.2.2 | 598 | 6/22/2020 |
2020.2.1 | 570 | 6/10/2020 |
2020.2.0 | 530 | 4/26/2020 |
2020.1.1 | 642 | 3/25/2020 |
2020.1.0 | 575 | 2/20/2020 |
2019.2.2 | 622 | 12/4/2019 |
2019.2.1 | 580 | 10/2/2019 |