C# StmpClient使用 网络(四)

 发送邮件

 1     //SmtpClient client = new SmtpClient("smtp.qq.com");
 2             //client.EnableSsl = true;
 3             //client.UseDefaultCredentials = false;
 4             //client.Credentials = new System.Net.NetworkCredential(email, key);
 5             //client.Send("from email", "to email", "Title", "Content");
 6 
 7 
 8             SmtpClient client = new SmtpClient("smtp.qq.com");
 9             client.EnableSsl = true;
10             client.UseDefaultCredentials = false;
11             client.Credentials = new System.Net.NetworkCredential("email", "key");
12             MailMessage m = new MailMessage();
13             m.From = new MailAddress("from email", "name");
14           
15             m.To.Add(new MailAddress("to email", "name"));
16             m.CC.Add(new MailAddress("cc email", "name"));
17 
18           
19             m.Subject = "This is Title";
20             m.Body = " long Message";
21             m.IsBodyHtml = true;
22             m.Priority = MailPriority.High;
23 
24             Attachment att = new Attachment("ad.zip", MediaTypeNames.Application.Zip); //项目路径下文件
25             m.Attachments.Add(att);
26              
27             client.Send(m);
原文地址:https://www.cnblogs.com/farmer-y/p/6114931.html