如题:用c#.net的net.mail发送邮件(简单实用)

 

 

 1c#.net 邮件发送        SmtpClient smtpClient = new SmtpClient();
 2c#.net 邮件发送        smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;//指定电子邮件发送方式
 3c#.net 邮件发送        smtpClient.Host = "smtp.sohu.com"; ;//指定SMTP服务器
 4c#.net 邮件发送        smtpClient.Credentials = new System.Net.NetworkCredential("xxx""yyy");//用户名和密码
 5c#.net 邮件发送
 6c#.net 邮件发送
 7c#.net 邮件发送        String body = "Test";
 8c#.net 邮件发送                
 9c#.net 邮件发送
10c#.net 邮件发送        MailMessage mailMessage = new MailMessage("xxx@sohu.com""297680@qq.com");
11c#.net 邮件发送        mailMessage.Subject = "Hello";//主题
12c#.net 邮件发送        mailMessage.Body = body;//内容
13c#.net 邮件发送        mailMessage.BodyEncoding = System.Text.Encoding.UTF8;//正文编码
14c#.net 邮件发送        mailMessage.IsBodyHtml = true;//设置为HTML格式
15c#.net 邮件发送        mailMessage.Priority = MailPriority.High;//优先级
16c#.net 邮件发送
17c#.net 邮件发送        try
18        }

 

 

 

注意引用命名空间

using System.Net.Mail;

相关文章:

  • 2021-10-02
猜你喜欢
  • 2022-03-05
  • 2021-08-01
  • 2022-12-23
  • 2022-12-23
  • 2022-01-29
  • 2021-06-25
  • 2022-01-31
相关资源
相似解决方案