Anton Putov
Anton Putov

Reputation: 1981

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?

Upvotes: 3

Views: 14061

Answers (1)

Moiz
Moiz

Reputation: 2439

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);

Upvotes: 5

Related Questions