- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Net;
- using System.Net.Mail;
-
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- SmtpClient smtp = new SmtpClient();
- smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
- smtp.EnableSsl = false;
- smtp.Host = "smtp.qq.com";
- smtp.Port = 25;
-
- smtp.UseDefaultCredentials = true;
-
- smtp.Credentials = new NetworkCredential("xxx@qq.com", "password");
- MailMessage mm = new MailMessage();
- mm.Priority = MailPriority.High;
- mm.From = new MailAddress("xxx@qq.com", "管理员", Encoding.GetEncoding(936));
-
-
-
-
-
-
-
-
-
-
- mm.CC.Add("xxx@qq.com");
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- mm.To.Add("xxx@sohu.com");
-
-
-
-
-
-
- mm.Subject = "这是测试邮件";
- mm.SubjectEncoding = Encoding.GetEncoding(936);
-
-
- mm.IsBodyHtml = true;
-
- mm.BodyEncoding = Encoding.GetEncoding(936);
-
-
- mm.Body = "<font color=‘red‘>邮件测试,呵呵</font>";
-
-
-
-
-
- try
- {
- smtp.Send(mm);
- }
- catch (Exception ex)
- {
- Console.WriteLine(ex.Message);
- }
- Console.Read();
- }
- }
- }
用.net 发送邮件
原文:http://www.cnblogs.com/just09161018/p/4605410.html