邮件发送
我要写一个发送邮件的功能,但不知道发邮件的基本思路,知道的朋友贴一下,谢了!
public static string SendEmail(string to, string subject, string confirmcode)
{
SmtpClient client = new SmtpClient("smtp.,25);
//SmtpClient client = new SmtpClient("smtp., 465);
//client.Host = "smtp.
//client.UseDefaultCredentials = false;
client.Credentials = new NetworkCredential("kevintangsa@, "?");? 这个是你的密码
//星号改成自己邮箱的密码
//client.DeliveryMethod =
client.EnableSsl = false;
MailMessage message = new MailMessage("kevintangsa@,to);
message.Subject = subject;
message.Body = confirmcode;
message.BodyEncoding = Encoding.UTF8;
message.IsBodyHtml = false;
//添加附件
//Attachment data = new Attachment(@"附件地址如:e:\a.jpg", );
//message.Attachments.Add(data);
try
{
client.Send(message);
return "成功";
}
catch (Exception ex)
{
return ex.Message;
}
}