一聚教程网:一个值得你收藏的教程网站

热门教程

asp.net C# 发送邮件实现代码

时间:2022-06-25 08:30:50 编辑:袖梨 来源:一聚教程网

asp教程.net c# 发送邮件实现代码

mailmessage mailmessage = new mailmessage();
mailmessage.to.add(this.txtto.text);
mailmessage.from = new system.net.mail.mailaddress(this.txtfrom.text);
mailmessage.subject = this.txttitle.text;
mailmessage.body = this.txtcontent.text;
mailmessage.isbodyhtml = true;
mailmessage.bodyencoding = system.text.encoding.utf8;
mailmessage.priority = system.net.mail.mailpriority.normal;

smtpclient smtpclient = new smtpclient();
smtpclient.credentials = new system.net.networkcredential(mailmessage.from.address, this.txtpassword.text);
smtpclient.deliverymethod = system.net.mail.smtpdeliverymethod.network;
smtpclient.host = "smtp." + mailmessage.from.host;
smtpclient.port = 25;
smtpclient.timeout = 3000;
smtpclient.enablessl = false;
smtpclient.send(mailmessage);


this.txtto.text 发送给谁

this.txtfrom.text 来自谁

this.txttitle.text 邮件标题

this.txtcontent.text 邮件内容

this.txtpassword.text 发送者邮箱密码

热门栏目