daily pastebin goal
42%
SHARE
TWEET

Untitled

a guest Jan 18th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. protected void SubmitBtn_Click(object sender, EventArgs e)
  2. {
  3.     if (Page.IsValid)
  4.     {
  5.         StringBuilder mailBody = new StringBuilder();
  6.         mailBody.Append("Company Name: " + companyText.Text.Trim() + "nn");
  7.         mailBody.Append("Name: " + firstNameText.Text.Trim() + " "
  8.             + lastNameText.Text.Trim() + "nn");
  9.         mailBody.Append("Email: " + emailText.Text.Trim() + "nn");
  10.  
  11.         if(!String.IsNullOrEmpty(tradeText.Text))
  12.             mailBody.Append("Trade: " + tradeText.Text.Trim() + "nn");
  13.  
  14.             bool success = SendEmail(emailText.Text.Trim(),
  15.                 companyText.Text.Trim(), "SubContractors Form Submission",
  16.                     mailBody.ToString());
  17.     }
  18. }
  19.  
  20. private bool SendEmail(string email, string name,
  21.     string subject, string message)
  22. {
  23.     using (MailMessage mail = new MailMessage())
  24.     {
  25.         mail.From = new MailAddress(BlogSettings.Instance.Email, name);
  26.         mail.ReplyTo = new MailAddress(email, name);
  27.  
  28.         mail.To.Add(BlogSettings.Instance.Email);
  29.         mail.Subject = subject;
  30.         mail.Body += message;
  31.  
  32.         if (Utils.SendMailMessage(mail).Length > 0)
  33.         {
  34.             return false;
  35.         };
  36.     }
  37.     return true;
  38. }
  39.    
  40. mail.Body += message.Replace("nn", "<br />");
  41.    
  42. mailBody.Append("Email: " + emailText.Text.Trim() + Environment.NewLine);
  43.    
  44. StringBuilder mailBody = new StringBuilder();
  45.  
  46. string company = companyText.Text.Trim();
  47. string firstName = firstNameText.Text.Trim();
  48. string lastName = lastNameText.Text.Trim();
  49. string email = emailText.Text.Trim();
  50. string trade = tradeText.Text.Trim();
  51.  
  52. mailBody.AppendFormat("Company Name: {0}", company).AppendLine();
  53. mailBody.AppendFormat("Name: {0} {1}", firstName, lastName).AppendLine();
  54. mailBody.AppendFormat("Email: {0}", email).AppendLine();
  55.  
  56. if(!string.IsNullOrEmpty(trade))
  57. {
  58.     mailBody.AppendFormat("Trade: {0}", trade).AppendLine();
  59. }
  60.  
  61. bool success = SendEmail(email, company, "SubContractors Form Submission",
  62.     mailBody.ToString());
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top