C# 调用163发送邮件
2022/1/27 14:34:33
本文主要是介绍C# 调用163发送邮件,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
private void sendMail2VistorSSL(Model.LeaveMsg msg) { var url = Request.Url.AbsoluteUri; var emailAcount = "anne@cXXX.com"; var emailPassword = "PenDsRXT3v";// "J17"; xia8gxh@163 "nqkqgff";// var reciver = msg.Email; var content = "<p>Thank you for your attention to Jack sewing machine!</p>" + "<p>We have received your message and we will contact with you as soon as possible!</p>" + "<p>Thanks again!</p>" + "<p>================================ you leave message =============================</p>" + // "<p>" + txt_Name.Text.Trim() + ", from " + txt_Country.Text.Trim() + ".</p>" + "<p>Left Message \"" + txt_Msg.Text.Trim() + "\" at </p>"; if (txt_Msg.Text.Trim().IndexOf("https") >= 0) { return; } content += Request.Url.AbsoluteUri; System.Web.Mail.MailMessage mail= new System.Web.Mail.MailMessage(); //设置发件人,发件人需要与设置的邮件发送服务器的邮箱一致 mail.From = emailAcount; //设置收件人,可添加多个,添加方法与下面的一样 mail.To = reciver; //设置抄送人 mail.Cc = "xiaofei2008gxh@163.com;" + emailAcount; //设置邮件标题 mail.Subject = "杰克官网访客留言信息"; //设置邮件内容 mail.Body = content; mail.BodyFormat = System.Web.Mail.MailFormat.Html; //message.BodyEncoding=System.Text.Encoding.GetEncoding( "gb2312 "); mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //身份验证 mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", mail.From); //邮箱登录账号,这里跟前面的发送账号一样就行 mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", emailPassword); //这个密码要注意:如果是一般账号,要用授权码;企业账号用登录密码 mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", 465);//端口 mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpusessl", "true");//SSL加密 System.Web.Mail.SmtpMail.SmtpServer = "smtp.exmail.qq.com"; //企业账号用smtp.exmail.qq.com System.Web.Mail.SmtpMail.Send(mail); }
这篇关于C# 调用163发送邮件的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2022-03-01沐雪多租宝商城源码从.NetCore3.1升级到.Net6的步骤
- 2024-11-18微软研究:RAG系统的四个层次提升理解与回答能力
- 2024-11-15C#中怎么从PEM格式的证书中提取公钥?-icode9专业技术文章分享
- 2024-11-14云架构设计——如何用diagrams.net绘制专业的AWS架构图?
- 2024-05-08首个适配Visual Studio平台的国产智能编程助手CodeGeeX正式上线!C#程序员必备效率神器!
- 2024-03-30C#设计模式之十六迭代器模式(Iterator Pattern)【行为型】
- 2024-03-29c# datetime tryparse
- 2024-02-21list find index c#
- 2024-01-24convert toint32 c#
- 2024-01-24Advanced .Net Debugging 1:你必须知道的调试工具