Hi guys,
I am using this code in local then it is working but when I am running the same code on
online then it is giving error so please let me know what can I do for it
i have giving my querry below
- protected void submit_Click(object sender, EventArgs e)
- {
- Sendmail("[email protected]", "[email protected]", "Contact Enquiry by New Customer", "[email protected]", "1234", name.Value , number.Value ,
- email.Value , message.Value);
- ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Thank You! We will contact you shortly…');location.href ='contactus.aspx';", true);
- //Response.Redirect("contactus.aspx");
- }
- public static void Sendmail(string frm, string to, string subj, string logid, string passwd, string name1,string number1,string email1,string msg1)
- {
- try
- {
- MailMessage Msg = new MailMessage();
- Msg.From = new MailAddress(frm);
- Msg.Subject = "New Customer Enquiry |" + email1 + "";
- //string Body += "Dear Sir,
"; - Msg.Body += "
";
- Msg.Body += "
"; ";- Msg.Body += "
";- Msg.Body += "
- Msg.Body += "
"; ";- Msg.Body += "
"; ";- // Msg.Body = "
Hello Brahmabull
from " + senderName2.Value + "
";- Msg.Body += "
Dear Sir ,
";- Msg.Body += "
Contact details are as mentioned below :
";- Msg.Body += "
Email Id:
"
+ email1+ "";- Msg.Body += "
Contact No.:
"
+ number1 + "";- Msg.Body += "
Customer Name:
"
+ name1+ "";- // Msg.Body += "
";- Msg.Body += "
Messege:
"
+ msg1 + "
";- Msg.Body += "
";- Msg.Body += "Regards By";
- Msg.Body += "
";- Msg.Body += "
"
+ name1 + "";- Msg.Body += "
- Msg.Body += "
- Msg.Body += "
"; ";- Msg.Body += "
";Copyright 2017 .
- Msg.Body += "
- Msg.Body += "
"; - Msg.Body += "
- Msg.IsBodyHtml = true;
- MailAddress objfrom = new MailAddress(frm);
- MailAddress objto = new MailAddress(to);
- Msg.Subject = subj;
- Msg.From = objfrom;
- Msg.To.Add(objto);
- //Msg.Body = body.ToString();
- SmtpClient smtp = new SmtpClient();
- smtp.Host = "smtp.gmail.com";
- smtp.Port = 25;
- smtp.Credentials = new System.Net.NetworkCredential("[email protected]", "1234");
- smtp.EnableSsl = true;
- smtp.Send(Msg);
- Msg = null;
- }
- catch (SmtpFailedRecipientException ex)
- {
- //message(ex.Message);
- }
- }
- }

Piyush PansuriyaPosted Oct 26, 2018, 1:03 AM