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

作者:袖梨 2022-06-25

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 发送者邮箱密码

相关文章

精彩推荐