如何通过c#SMTP发送电子邮件
本文关键字:电子邮件 c#SMTP 何通过 | 更新日期: 2023-09-27 18:00:37
我想通过C#发送电子邮件,如何以正确的方式发送?我应该使用
System.Net.Mail
MailMessage mail = new MailMessage();
现在呢?
SmtpClient SmtpServer = new SmtpClient("mail.provider.com.br");
mail.From = new MailAddress("noreply@provider.com.br");
mail.To.Add("youremail@provider.com.br");
mail.Subject = "Some title";
mail.Body = "YOUR TEXT GOES HERE";
SmtpServer.Port = 'port';
//credentials
SmtpServer.Credentials = new System.Net.NetworkCredential("youremail@provider.com.br", "pa$$word");
SmtpServer.Send(mail);