![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
string v_smtpAddress ="smtp.qq.com";//smtp地址,如smtp.163.com
string v_sendMailUserName = "myqq@qq.com";//发送邮件使用的用户名
string v_sendMailPassword = "mypassword";//发送邮件使用的密码
string v_sendMailAddress = "myqq@qq.com";//发送邮件的mail地址
string v_receiveMailAddress = "yourqq@qq.com;";//接收邮件的mail地址
string v_mailSubject = "title";//邮件主题
SmtpClient smtp = new SmtpClient(v_smtpAddress);
smtp.Credentials = new System.Net.NetworkCredential(v_sendMailUserName, v_sendMailPassword);
MailMessage mes = new MailMessage();
mes.From = new MailAddress(v_sendMailAddress);
mes.To.Add(v_receiveMailAddress);
mes.Subject = v_mailSubject;
mes.Body ="this is body";
mes.IsBodyHtml = true;//使用是否html格式
//增加附件
// System.Net.Mail.Attachment mailAttach_1 = new Attachment(@"d:\b.txt");
//mes.Attachments.Add(mailAttach_1);
for (int i = 0; i < 20; i++)
{
//循环发送多次,可不要乱发垃圾哦~
smtp.Send(mes);
}
//mailAttach_1.Dispose();//释放由附件占用的资源
//myHander h = speak;
//h += speak2;
//Delegate[] handers = h.GetInvocationList();
//foreach (myHander a in handers)
//{
// Console.WriteLine(h());
//}
Console.WriteLine("success");