1、安装Nuget包MailKit,引用命名空间。

using MailKit.Net.Smtp;
using MimeKit;
注意:引用MailKit对应最新版本

2、定义收发地址和标题

MimeMessage message = new MimeMessage();
MailboxAddress from = new MailboxAddress("Admin","admin@example.com");
message.From.Add(from);
MailboxAddress to = new MailboxAddress("User", "user@example.com");
message.To.Add(to);
message.Subject = "This is email subject";
注意:Admin,User分别对应发送接收邮箱前缀

3、编写内容

BodyBuilder bodyBuilder = new BodyBuilder();
bodyBuilder.HtmlBody = "<h1>Hello World!</h1>";
bodyBuilder.TextBody = "Hello World!";
message.Body = bodyBuilder.ToMessageBody();
注意:也可以自定义模板,插入图片等等。

4、连接SMTP服务器发送邮件

SmtpClient client = new SmtpClient();
client.Connect("smtp_address_here", port_here, true);  //例如:smtp.exmail.qq.com,465
client.Authenticate("admin@example.com", "password"); //发送邮件的账户密码
client.Send(message);
client.Disconnect(true);
client.Dispose();

.Net Core Send Email的更多相关文章

  1. Try to write a script to send e-mail but failed

    #-*-coding: utf-8 -*- '''使用Python去发送邮件但是不成功,运行后,等待一段时间, 返回[Errno 10060] A connection attempt failed ...

  2. python auto send email

    /*************************************************************************** * python auto send emai ...

  3. Check SMTP Server Availability for ORA-29278 or ORA-29279 errors using UTL_SMTP to Send Email

    Check SMTP Server Availability for ORA-29278 or ORA-29279 errors using UTL_SMTP to Send Email. (文档 I ...

  4. Send Email in Robot Framework Python Using Gmail

    转载自:http://seleniummaster.com/sitecontent/index.php/selenium-robot-framework-menu/selenium-robot-fra ...

  5. 5 Ways to Send Email From Linux Command Line

    https://tecadmin.net/ways-to-send-email-from-linux-command-line/ We all know the importance of email ...

  6. [476] Database Mail is not enabled for agent notifications. Cannot send e-mail to

    配置完DB Mail后JOB的的通知邮件不能发送,日志报错476] Database Mail is not enabled for agent notifications. Cannot send ...

  7. Send Email in .NET Core 2.0

    在.NET Core 1.0 中,SMTP Client代码并没有被移植,直到.NET Core 2.0的发布.使用下面的代码: static void Main(string[] args) { S ...

  8. Send email alert from Performance Monitor using PowerShell script (检测windows服务器的cpu 硬盘 服务等性能,发email的方法) -摘自网络

    I have created an alert in Performance Monitor (Windows Server 2008 R2) that should be triggered whe ...

  9. Send Email

    private string SendEmail(string mailTo, string body, ref int sendresult) { string errorEmailAddress ...

随机推荐

  1. 阅读了这三篇文章,你也就基本理解了ASP.NET Core MVC框架的工作原理

    <200行代码,7个对象--让你了解ASP.NET Core框架的本质>让很多读者对ASP.NET Core管道有深刻的理解,知道了ASP.NET Core框架针对每个请求的处理流程.在过 ...

  2. OpenCV-Python 模板匹配 | 三十一

    目标 在本章中,您将学习 使用模板匹配在图像中查找对象 你将看到以下功能:cv.matchTemplate(),cv.minMaxLoc() 理论 模板匹配是一种用于在较大图像中搜索和查找模板图像位置 ...

  3. Tensorflow系列专题(四):神经网络篇之前馈神经网络综述

    目录: 神经网络前言 神经网络 感知机模型 多层神经网络 激活函数 Logistic函数 Tanh函数 ReLu函数 损失函数和输出单元 损失函数的选择 均方误差损失函数 交叉熵损失函数 输出单元的选 ...

  4. Java中如何调用静态方法

    Java中如何调用静态方法: 1.如果想要调用的静态方法在本类中,可直接使用方法名调用 2.调用其他类的静态方法,可使用类名.方法名调用 关于静态方法能被什么调用 1.实例方法 2.静态发放

  5. Python批量修改文件名模板

    源码如下:import os import re import sys filePath = r'F:\BaiduNetdiskDownload\COVID-19CTSeg\3DUNet-Pytorc ...

  6. Gin框架系列01:极速上手

    Gin是什么? Gin是Go语言编写的web框架,具备中间件.崩溃处理.JSON验证.内置渲染等多种功能. 准备工作 本系列演示所有代码都在Github中,感兴趣的同学可以自行查阅,欢迎大家一起完善. ...

  7. Windows 7集成IE11(离线安装包、补丁)

    当Win7系统需要集成IE11时,我们需要提前打入6个补丁 KB2731771.KB2786081.KB2834140.KB2670838.KB2729094.KB2533623 32位 ★百度网盘 ...

  8. win10 系统中vscode 的终端 shell 设置

    今天,打算开始搞一个个人博客小项目. 主力台式电脑在实验室,于是重新配了一下自己的小破笔记本.系统是之前自己捣鼓的 win10 .在打开终端调试 node 时,发现报了这么一个错. 我刚开始以为是自己 ...

  9. DOS命令集

    1.ASSOC显示或修改文件扩展名关联.ASSOC [.ext[=[fileType]]]  .ext      指定跟文件类型关联的文件扩展名  fileType  指定跟文件扩展名关联的文件类型键 ...

  10. Round 1A 2020 - Code Jam 2020

    Problem A. Pattern Matching 把每个字符串分成第一个之前,最后一个之后,中间的部分 三个部分 每个字符串的中间的部分可以直接拼接 前后两个部分需要判断下是否合法 #inclu ...