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);
-
- }
- 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 + "";
-
- Msg.Body += "<table width='600px' bgcolor='#f6f8f1' border='1' cellpadding='1' cellspacing='1'>";
- Msg.Body += "<tr>";
- Msg.Body += "<td align='center'><img src='http://ritzeggcafe.com/images/logo2.png' class='img-responsive' alt=''/></td>";
- Msg.Body += "</tr>";
- Msg.Body += "<tr>";
- Msg.Body += "<td style='padding-left:15px;'>";
-
- Msg.Body += "<h3>Dear <b> Sir </b>,</h3>";
- Msg.Body += "<h4>Contact details are as mentioned below :</h4>";
- Msg.Body += "<h3>Email Id: </h3><p>" + email1+ "</p>";
- Msg.Body += "<h3>Contact No.</p>: </h3><p>" + number1 + "</p>";
- Msg.Body += "<h3>Customer Name: </h3><p>" + name1+ "</p>";
-
- Msg.Body += "<h3><b>Messege: </b></h3><p>" + msg1 + "<br/></p>";
- Msg.Body += " <br/>";
- Msg.Body += "Regards By";
- Msg.Body += " <br/>";
- Msg.Body += "<h3><b>" + name1 + "</b></h3>";
- Msg.Body += "</td>";
- Msg.Body += "</tr>";
- Msg.Body += "<tr>";
- Msg.Body += "<td align='center'><h5>Copyright 2017 .</h5></td>";
- Msg.Body += "</tr>";
- Msg.Body += "</table><br/>";
- Msg.IsBodyHtml = true;
- MailAddress objfrom = new MailAddress(frm);
- MailAddress objto = new MailAddress(to);
- Msg.Subject = subj;
- Msg.From = objfrom;
- Msg.To.Add(objto);
-
- 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)
- {
-
- }
- }
- }