1 MailMessage mail = new MailMessage();
2 mail.From = new MailAddress("发件人邮箱");
3 mail.To.Add(new MailAddress("收件人邮箱"));
4 mail.Subject = "标题字符串";
5 mail.Body = "内容字符串";
6 mail.Attachments.Add(new Attachment(@"附件地址"));
7 SmtpClient sc = new SmtpClient("Smtp服务器地址或域名");
8 sc.Credentials = new NetworkCredential("发件人邮箱", "发件人密码");
9 sc.Send(mail);
10 sc.Dispose();
代码很容易看懂,主要是需要发件人的邮箱开启SMTP服务,今天中午用这段代码套在循环里写了个恶意邮件轰炸机,小有成就感,可是发现循环10000次对方只能收到20来封,有待继续研究...
MailMessage mail = new MailMessage();
mail.From = new MailAddress("发件人邮箱");
mail.To.Add(new MailAddress("收件人邮箱"));
mail.Subject = "标题字符串";
mail.Body = "内容字符串";
mail.Attachments.Add(new Attachment(@"附件地址"));
SmtpClient sc = new SmtpClient("Smtp服务器地址或域名");
sc.Credentials = new NetworkCredential("发件人邮箱", "发件人密码");
sc.Send(mail);
sc.Dispose();