Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

send email in asp.net from localhost

I find this solution for sending mail but it gives me eror.Here my values:

Message to: [email protected]

Message from: [email protected]

subject: ....
.........

I am using visual studio 2010.Must I set any configuration properties or something else?

like image 784
Anton Putov Avatar asked Dec 17 '25 14:12

Anton Putov


1 Answers

What type of SMTP you are using ? If you dont have your own SMTP settings then you can Use of Google Mail. Here how you can use that.

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("[email protected]");
  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
       ("[email protected]","YourGmailPassword");
//Or your Smtp Email ID and Password
  smtp.EnableSsl = true;
  smtp.Send(mail);
like image 181
Moiz Avatar answered Dec 20 '25 07:12

Moiz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!