[英]How to send mails through smtp in c#
如何在C#中通过SMTP发送邮件
System.Net.Mail.MailMessage与System.Net.Mail.SmtpClient结合使用
MailMessage mail = new MailMessage();
mail.From = new MailAddress("from address");
mail.Subject = "subject";
mail.Body = "body";
mail.IsBodyHtml = IsHtml;
mail.To.Add("targetaddress");
SmtpClient mailClient = new SmtpClient("smtphost");
mailClient.Credentials = new NetworkCredential("username", "password", "domain");
try
{
mailClient.Send(mail);
}
catch (Exception ex)
{
throw ex;
}
finally
{
mailClient = null;
}
看一下System.Net.Mail.SmtpClient参考。 它应该是您要寻找的
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.