Loading... # NETCore.MailKit ## 安装 nuget ``` Install-Package NETCore.MailKit -Version 2.1.0 ``` CLI ``` dotnet add package NETCore.MailKit --version 2.1.0 ``` ## 使用 ![](https://oss.hunji.xyz/blogoss/202310/1920368-20230718143228831-975826673.png) ![](https://oss.hunji.xyz/blogoss/202310/1920368-20230718143133474-1168472621.png) ![](https://oss.hunji.xyz/blogoss/202310/1920368-20230718143204085-1500744674.png) ![](https://oss.hunji.xyz/blogoss/202310/1920368-20230718143114139-695432283.png) #### 注册 ```csharp public void ConfigureServices(IServiceCollection services) { // Add framework services. services.AddMvc(); //Add MailKit services.AddMailKit(optionBuilder => { optionBuilder.UseMailKit(new MailKitOptions() { //get options from sercets.json Server = Configuration["Server"], Port = Convert.ToInt32(Configuration["Port"]), SenderName = Configuration["SenderName"], SenderEmail = Configuration["SenderEmail"], // can be optional with no authentication Account = Configuration["Account"], Password = Configuration["Password"], // enable ssl or tls Security = true }); }); } ``` #### 调用 ```csharp public class HomeController : Controller { private readonly IEmailService _EmailService; public HomeController(IEmailService emailService) { _EmailService = emailService; } public IActionResult Email() { ViewData["Message"] = "ASP.NET Core mvc send email example"; _EmailService.Send("xxxx@gmail.com", "ASP.NET Core mvc send email example", "Send from asp.net core mvc action"); return View(); } } ``` ## 项目地址 项目地址:https://github.com/myloveCc/NETCore.MailKit #### 推荐阅读 - [开源项目MiniWord .NET Word-Word操作](https://mp.weixin.qq.com/s/-_aVbQjFft63EwLkJdzuEQ) - [博客系统必备-Moonglade Blog](https://mp.weixin.qq.com/s/wfcYZLPok8VnTK4fwDMp_A) - [C#编写的一款电子桌面宠物-Candy](https://mp.weixin.qq.com/s/51djCV3_u7qIqDuomA8_qw) - [ShellProgressBar控制台中漂亮的显示进度条](https://mp.weixin.qq.com/s/dY-4svHo5yJ03EDs0ZWGtg) - [控制台必备神器-AnsiConsole](https://mp.weixin.qq.com/s/FBDJKIOVR6swXBAYUwd7cg) - [WPFUI_直观的设计主题导航和新的沉浸式控件](https://mp.weixin.qq.com/s/D-jvb3CNSYVw11j59fji_g) - [一款的 WPF 主题和控件包,免费开源](https://mp.weixin.qq.com/s/5zCfz2XyLi4NeJM9HQf8Ow) - [Net开源项目-一款电子邮件神奇](https://mp.weixin.qq.com/s/sH9vviKLf-C0GAfb1ilI5Q) - [NET 7 + Vue.js 的前后端分离的通用后台管理系统框架](https://mp.weixin.qq.com/s/mM8de7hnjq24H20ifjsm4g) 欢迎关注我的公众号“**Net分享**”,技术文章第一时间推送,随缘更新 , 分享一些你可能注意不到的细节。 <center> <img src="https://oss.hunji.xyz/blogoss/202310/1920368-20221018151428175-1348767064.jpg" style="width: 140px;"> </center> 最后修改:2023 年 10 月 10 日 © 允许规范转载 打赏 赞赏作者 支付宝微信 赞 如果觉得我的文章对你有用,请随意赞赏