[英]send email in asp.net from localhost
我發現這個發送郵件的解決方案,但它讓我感到很恐怖。這是我的價值觀:
Message to: anton_putov@mail.ru
Message from: anton_putov@mail.ru
subject: ....
.........
我正在使用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);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.