MailMessage msg = new MailMessage();
msg.From = new MailAddress(txtEmail.Text);
msg.To.Add("mymailid");
msg.IsBodyHtml = true;
msg.Body = "Name : " + txtname.Text + "
Email : " + txtEmail.Text + "
Phone : " + txtmobile.Text + "
Message : " + Txtmessage.Text + "
";
Email : " + txtEmail.Text + "
Phone : " + txtmobile.Text + "
Message : " + Txtmessage.Text + "
";
msg.Subject = txtSubject.Text;
SmtpClient smtpclient = new SmtpClient();
smtpclient.Host = "smtp.gmail.com";
smtpclient.Port = 587;
smtpclient.Credentials = new System.Net.NetworkCredential("mymailid", "password");
smtpclient.EnableSsl = true;
smtpclient.Send(msg);
Label1.Text = "Thanks for contacting us";
txtname.Text = "";
txtEmail.Text = "";
txtSubject.Text = "";
Txtmessage.Text = "";
txtmobile.Text = "";
}
catch(Exception ex)
{
Console.WriteLine("{0} Exeception caugh.",ex);
}
this code of mine working on local host but not working when i put it on server can an one suggest me what to do.
Dipankar BiswasRank #992 · 2K reputationPosted Aug 2, 2014, 9:47 AM EDT
shilpa mittal9 reputationPosted Aug 2, 2014, 11:20 PM EDT
Dipankar BiswasRank #992 · 2K reputationPosted Aug 3, 2014, 2:21 AM EDT
shilpa mittal9 reputationPosted Aug 3, 2014, 2:31 AM EDT
Dipankar BiswasRank #992 · 2K reputationPosted Aug 3, 2014, 4:38 AM EDT
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts