Hi,
I have create web application send mail. i use this code
con.Open();
com = new SqlCommand("select mailid,password='" + TextBox2.Text + "' from registration where userid='" + TextBox1.Text + "'", con);
dr = com.ExecuteReader();
if (dr.Read())
{
mid = dr["mailid"].ToString();
var fromAddress = new MailAddress("
[email protected]", "Cloud Storage");
var toAddress = new MailAddress(mid, "Cloud Storage");
const string fromPassword = "pa$$word123";
const string subject = "Verification Code";
int n = _r.Next();
body = n.ToString();
Session["msg"] = body.ToString();
var smtp = new SmtpClient
{
Host = "smtp.gmail.com",
Port = 587,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new NetworkCredential(fromAddress.Address, fromPassword)
};
using (var message = new MailMessage(fromAddress, toAddress)
{
Subject = subject,
Body = body
})
{
smtp.Send(message);
//smtp.Send(message);
}
Session["Username"] = TextBox1.Text.ToString();
Response.Redirect ("Verification.aspx");
}
else
{
Response.Write("Invalid Login");
}
but error at not remote server (sending failed) so how to set smtp server