using System.Net.Mail; MailAddress form = new MailAddress("XXXXX@gmail.com", "我的Gmail"); MailAddress to = new MailAddress("XXXXX@gmail.com"); //邮件 MailMessage mm = new MailMessage(form, to); //邮件标题 mm.Subject = "emailTitle"; mm.SubjectEncoding = System.Text.Encoding.UTF8; mm.Body = "内容"; mm.BodyEncoding = System.Text.Encoding.UTF8; // SmtpClient smtp = new SmtpClient("smtp.gmail.com",587);后面的服务器端口号,可以不填 SmtpClient smtp = new SmtpClient("smtp.gmail.com"); smtp.EnableSsl = true; smtp.Credentials = new NetworkCredential("XXXXX@gmail.com", "邮箱密码");//发送邮件的用户名 smtp.Send(mm);