View Code
1 System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();
2 client.Host = "smtp.qq.com";
3 client.UseDefaultCredentials = false;
4 client.Credentials = new System.Net.NetworkCredential("邮箱用户名", "邮箱密码");
5 client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
6 System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage("发件人的邮箱", "收件人的邮箱");
7 message.Subject = "关于XX的处罚决定";
8 message.Body = "<center>关于XX的处罚决定</center><br/>关于XX的处罚决定关于XX的处罚决定关于XX的处罚决定关于XX的处罚决定";
9 message.BodyEncoding = Encoding.UTF8;
10 message.IsBodyHtml = true;
11 System.Net.Mail.Attachment m;//附件
12 if (this.FileUpload1.HasFile)
13 {
14 m = new System.Net.Mail.Attachment(this.FileUpload1.PostedFile.FileName);
15 message.Attachments.Add(m);
16 }
17 client.Send(message);