asp.net2.0发送邮件
public static string SendMail(string smtp, string userName, string password, string title, string content, string send, string accept)
{
string result = string.Empty;
SmtpClient client = new SmtpClient(smtp);
client.UseDefaultCredentials = false;
client.Credentials = new NetworkCredential(userName, password);
client.DeliveryMethod = SmtpDeliveryMethod.Network;
MailMessage message = new MailMessage();
message.SubjectEncoding = Encoding.UTF8;
message.BodyEncoding = Encoding.UTF8;
message.From = new MailAddress(send, "loveayu", Encoding.UTF8);
message.To.Add(new MailAddress(accept, "xiaOhui", Encoding.UTF8));
message.IsBodyHtml = false;
message.Subject = title;
message.Body = content;
try
{
client.Send(message);
result = "操作成功";
}
catch (Exception sendE)
{
result = sendE.Message;
}
return result;
}
需要引进的命名空间是
using System.Net;
using System.Net.Mail;