-
Notifications
You must be signed in to change notification settings - Fork 0
/
SendEmail.linq
35 lines (31 loc) · 1.2 KB
/
SendEmail.linq
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<Query Kind="Program">
<NuGetReference>FluentEmail.Core</NuGetReference>
<NuGetReference>FluentEmail.Smtp</NuGetReference>
<Namespace>System.Threading.Tasks</Namespace>
<IncludeUncapsulator>false</IncludeUncapsulator>
</Query>
//#r "nuget:FluentEmail.Smtp/2.8.0"
using System.Net;
using System.Net.Mail;
using FluentEmail;
using FluentEmail.Core;
using FluentEmail.Smtp;
async Task Main()
{
string myEmailAddress = "[email protected]";
string myEmailSmtpPassword = "KISSOWAUZTENWMLL";//从163中开启Smtp服务并新增授权密码
string toEmailAddress = "[email protected]";
SmtpClient smtp = new SmtpClient
{
EnableSsl = false,
Host = "smtp.163.com",
UseDefaultCredentials = false,
DeliveryMethod = SmtpDeliveryMethod.Network,
//这里输入你在发送smtp服务器的用户名和密码
Credentials = new NetworkCredential(myEmailAddress, myEmailSmtpPassword)
};
Email.DefaultSender = new SmtpSender(smtp);
var email = await Email.From(myEmailAddress, "wwmin").To(toEmailAddress, "wwmin").Subject("test send email").Body("测试发送邮件,时间:" + DateTime.Now).SendAsync();
email.Successful.Dump();
}
// You can define other methods, fields, classes and namespaces here