Ant*_*tov 3 asp.net email smtp localhost
我发现这个 发送邮件的解决方案,但它让我感到很恐怖.这是我的价值观:
Message to: anton_putov@mail.ru
Message from: anton_putov@mail.ru
subject: ....
.........
Run Code Online (Sandbox Code Playgroud)
我正在使用visual studio 2010.我必须设置任何配置属性或其他东西吗?
您正在使用哪种类型的SMTP?如果您没有自己的SMTP设置,则可以使用Google Mail。在这里,您可以如何使用它。
MailMessage mail = new MailMessage();
mail.To.Add("Email ID where email is to be send");
mail.To.Add("Another Email ID where you wanna send same email");
mail.From = new MailAddress("YourGmailID@gmail.com");
mail.Subject = "Email using Gmail";
string Body = "Hi, this mail is to test sending mail"+
"using Gmail in ASP.NET";
mail.Body = Body;
mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com"; //Or Your SMTP Server Address
smtp.Credentials = new System.Net.NetworkCredential
("YourUserName@gmail.com","YourGmailPassword");
//Or your Smtp Email ID and Password
smtp.EnableSsl = true;
smtp.Send(mail);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10788 次 |
| 最近记录: |