using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Mail;
using System.Text;
using System.Threading.Tasks;
namespace SendEmail
{
class Program
{
static void Main(string[] args)
{
MailMessage mailMsg = new MailMessage();
// 发件人邮箱
mailMsg.From = new MailAddress("test@sina.cn", "钱氏集团");
// 收件人邮箱,可以有多个收件人
mailMsg.To.Add(new MailAddress("test@qq.com", "无边落木"));
// 抄送人邮箱,可以有多个抄送人
mailMsg.CC.Add(new MailAddress("testtest@163.com", "dsfsf"));
// 发送邮件的标题
mailMsg.Subject = "关于国庆节放假通知";
// 发送邮件的内容
mailMsg.Body = "10月1号至3号加班,4号至18号放假!";
// 将附件附加到邮件消息对象中 ,可以有多个附件。
mailMsg.Attachments.Add(new Attachment(@"C:UsersTOMDesktop1.jpg"));
// 发送邮件的服务器
SmtpClient client = new SmtpClient("smtp.sina.cn");
// 指定发件人的邮箱及邮箱密码
client.Credentials = new NetworkCredential("test@sina.cn", "123456");
client.Send(mailMsg);
Console.WriteLine("发送成功");
Console.ReadKey();
}
}
}