文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>C# 发送邮件

C# 发送邮件

时间:2011-03-10  来源:xiao张

C# 发送邮件代码备忘

this.txtTo.Text 发送给谁

this.txtFrom.Text 来自谁

this.txtTitle.Text 邮件标题

this.txtContent.Text 邮件内容

this.txtPassword.Text 发送者邮箱密码

代码如下:

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);
相关阅读 更多 +
排行榜 更多 +
找茬脑洞的世界安卓版

找茬脑洞的世界安卓版

休闲益智 下载
滑板英雄跑酷2手游

滑板英雄跑酷2手游

休闲益智 下载
披萨对对看下载

披萨对对看下载

休闲益智 下载