用c#如何编写发送邮件
展开全部
public bool Send()
{
SmtpClient client = new SmtpClient();
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.EnableSsl = false;
client.Port= 25;
client.Host = "smtp.163.com";
client.Credentials = new NetworkCredential(123@163.com, 1234);//发件人,密码
MailMessage mm = new MailMessage();
mm.Priority = MailPriority.High;
mm.From = new MailAddress(123@163.com);//发件人验证
mm.Sender = new MailAddress(123@163.com);//发件人验证
mm.To.Add(new MailAddress(2134@163.com));//收件人
mm.Subject = "SMSPro Client Test Email!";
mm.Body = "SMSPro Client Test Email!";
mm.IsBodyHtml = true;
try
{
client.Send(mm);
return true;
}
catch
{
return false;
}
}
{
SmtpClient client = new SmtpClient();
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.EnableSsl = false;
client.Port= 25;
client.Host = "smtp.163.com";
client.Credentials = new NetworkCredential(123@163.com, 1234);//发件人,密码
MailMessage mm = new MailMessage();
mm.Priority = MailPriority.High;
mm.From = new MailAddress(123@163.com);//发件人验证
mm.Sender = new MailAddress(123@163.com);//发件人验证
mm.To.Add(new MailAddress(2134@163.com));//收件人
mm.Subject = "SMSPro Client Test Email!";
mm.Body = "SMSPro Client Test Email!";
mm.IsBodyHtml = true;
try
{
client.Send(mm);
return true;
}
catch
{
return false;
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询