程序发送邮件代码

MailMessage mailMessage = new MailMessage();
mailMessage.From = new MailAddress("[email protected]", "bbb");
mailMessage.To.Add(new MailAddress("[email protected]","aaa"));
mailMessage.Subject = "邮件啊";
byte[] bytes;

bytes = Encoding.UTF8.GetBytes("真个无人能比");
mailMessage.Body = Encoding.UTF8.GetString(bytes);

SmtpClient smtpClient = new SmtpClient("127.0.0.1");
smtpClient.Credentials = new System.Net.NetworkCredential("bbb","bbb");
smtpClient.Send(mailMessage);

你可能感兴趣的:(发送邮件)