C#发送邮件
2021-01-25 21:14
标签:als time timesheet str connect end 参考 client body 参考:https://stackoverflow.com/questions/13506623/smtp-exception-failure-sending-mail C#发送邮件 标签:als time timesheet str connect end 参考 client body 原文地址:https://www.cnblogs.com/shy1766IT/p/12006129.html MailSettings.SMTPServer = Convert.ToString(ConfigurationManager.AppSettings["HostName"]);
MailMessage Msg = new MailMessage();
// Sender e-mail address.
Msg.From = new MailAddress("pqr@gmail.com");
// Recipient e-mail address.
Msg.To.Add("abc@gmail.com");
Msg.CC.Add("zcd@gmail.com");
Msg.Subject = "Timesheet Payment Instruction updated";
Msg.IsBodyHtml = true;
Msg.Body = emailMessage.ToString();
NetworkCredential loginInfo = new NetworkCredential(Convert.ToString(ConfigurationManager.AppSettings["UserName"]), Convert.ToString(ConfigurationManager.AppSettings["Password"])); // password for connection smtp if u dont have have then pass blank
SmtpClient smtp = new SmtpClient();
smtp.UseDefaultCredentials = true;
smtp.Credentials = loginInfo;
//smtp.EnableSsl = true;
//No need for port
//smtp.Host = ConfigurationManager.AppSettings["HostName"];
//smtp.Port = int.Parse(ConfigurationManager.AppSettings["PortNumber"]);
smtp.Send(Msg);
上一篇:网络接口api