Jitendra Kumar

Jitendra Kumar

  • NA
  • 189
  • 22k

Please solve it my querry send email

Oct 26 2018 12:50 AM
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
  1. protected void submit_Click(object sender, EventArgs e)  
  2. {  
  3. Sendmail("[email protected]""[email protected]""Contact Enquiry by New Customer""[email protected]""1234", name.Value , number.Value ,  
  4. email.Value , message.Value);  
  5. ClientScript.RegisterStartupScript(this.GetType(), "alert""alert('Thank You! We will contact you shortly…');location.href ='contactus.aspx';"true);  
  6. //Response.Redirect("contactus.aspx");  
  7. }  
  8. public static void Sendmail(string frm, string to, string subj, string logid, string passwd, string name1,string number1,string email1,string msg1)  
  9. {  
  10. try  
  11. {  
  12. MailMessage Msg = new MailMessage();  
  13. Msg.From = new MailAddress(frm);  
  14. Msg.Subject = "New Customer Enquiry |" + email1 + "";  
  15. //string Body += "Dear Sir, <br/>";  
  16. Msg.Body += "<table width='600px' bgcolor='#f6f8f1' border='1' cellpadding='1' cellspacing='1'>";  
  17. Msg.Body += "<tr>";  
  18. Msg.Body += "<td align='center'><img src='http://ritzeggcafe.com/images/logo2.png' class='img-responsive' alt=''/></td>";  
  19. Msg.Body += "</tr>";  
  20. Msg.Body += "<tr>";  
  21. Msg.Body += "<td style='padding-left:15px;'>";  
  22. // Msg.Body = "<h1>Hello Brahmabull </h1><h3>from  " + senderName2.Value + " </b><br/></h3>";  
  23. Msg.Body += "<h3>Dear <b> Sir </b>,</h3>";  
  24. Msg.Body += "<h4>Contact details are as mentioned below :</h4>";  
  25. Msg.Body += "<h3>Email Id: </h3><p>" + email1+ "</p>";  
  26. Msg.Body += "<h3>Contact No.</p>: </h3><p>" + number1 + "</p>";  
  27. Msg.Body += "<h3>Customer Name: </h3><p>" + name1+ "</p>";  
  28. // Msg.Body += " <br/>";  
  29. Msg.Body += "<h3><b>Messege: </b></h3><p>" + msg1 + "<br/></p>";  
  30. Msg.Body += " <br/>";  
  31. Msg.Body += "Regards By";  
  32. Msg.Body += " <br/>";  
  33. Msg.Body += "<h3><b>" + name1 + "</b></h3>";  
  34. Msg.Body += "</td>";  
  35. Msg.Body += "</tr>";  
  36. Msg.Body += "<tr>";  
  37. Msg.Body += "<td align='center'><h5>Copyright 2017 .</h5></td>";  
  38. Msg.Body += "</tr>";  
  39. Msg.Body += "</table><br/>";  
  40. Msg.IsBodyHtml = true;  
  41. MailAddress objfrom = new MailAddress(frm);  
  42. MailAddress objto = new MailAddress(to);  
  43. Msg.Subject = subj;  
  44. Msg.From = objfrom;  
  45. Msg.To.Add(objto);  
  46. //Msg.Body = body.ToString();  
  47. SmtpClient smtp = new SmtpClient();  
  48. smtp.Host = "smtp.gmail.com";  
  49. smtp.Port = 25;  
  50. smtp.Credentials = new System.Net.NetworkCredential("[email protected]""1234");  
  51. smtp.EnableSsl = true;  
  52. smtp.Send(Msg);  
  53. Msg = null;  
  54. }  
  55. catch (SmtpFailedRecipientException ex)  
  56. {  
  57. //message(ex.Message);  
  58. }  
  59. }  
  60. }  

Answers (1)