当前位置: 移动技术网 > IT编程>开发语言>.net > .net core 发送邮件

.net core 发送邮件

2019年01月16日  | 移动技术网IT编程  | 我要评论

徐海乔的别名,tokyo hot n0762,丫康王

   var message = new mimemessage();
            //发送方
            message.from.add(new mailboxaddress("liyy", "xxxxx.com"));
            //接受方
            message.to.add(new mailboxaddress("mrs. li", "xxxxx.com"));
            //标题
            message.subject = "周末去哪嗨?";
            //文字内容
            message.body = new textpart("plain") { text = "上海一日游" };
            //开始发送
            using (var client = new mailkit.net.smtp.smtpclient())
            {
                client.servercertificatevalidationcallback = (s, c, h, e) => true;
                client.connect("smtp.live.com", 465, true);
                client.authenticationmechanisms.remove("xoauth2");
                client.authenticate("发送方邮箱", "发送方邮箱smtp授权码");
                client.send(message);
                client.disconnect(true);
            }

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网