Advertisement
Guest User

Untitled

a guest
Mar 9th, 2019
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.65 KB | None | 0 0
  1. <form action="#">
  2. <p>Please contact us</p>
  3. <input type="text" maxlength="30" value="Name" class="textcontact" />
  4. <input type="text" maxlength="30" value="E-mail Address" class="textcontact" />
  5. <input type="text" maxlength="30" value="Subject" class="textcontact" />
  6. <textarea name="message" id="message" cols="30" rows="10"></textarea>
  7. <input type="submit" value="" class="submit" />
  8. </form>
  9.  
  10. <!DOCTYPE html>
  11. <html>
  12. <head>
  13. <title>Request for Assistance</title>
  14. </head>
  15. <body>
  16. <h2>Submit Email Request for Assistance</h2>
  17. <form method="post" action="ProcessRequest.cshtml">
  18. <div>
  19. Your name:
  20. <input type="text" name="customerName" />
  21. </div>
  22.  
  23. <div>
  24. Your email address:
  25. <input type="text" name="customerEmail" />
  26. </div>
  27.  
  28. <div>
  29. Details about your problem: <br />
  30. <textarea name="customerRequest" cols="45" rows="4"></textarea>
  31. </div>
  32.  
  33. <div>
  34. <input type="submit" value="Submit" />
  35. </div>
  36. </form>
  37. </body>
  38. </html>
  39.  
  40. @{
  41. var customerName = Request["customerName"];
  42. var customerEmail = Request["customerEmail"];
  43. var customerRequest = Request["customerRequest"];
  44. var errorMessage = "";
  45. var debuggingFlag = false;
  46. try {
  47. // Initialize WebMail helper
  48. WebMail.SmtpServer = "your-SMTP-host";
  49. WebMail.SmtpPort = 25;
  50. WebMail.UserName = "your-user-name-here";
  51. WebMail.Password = "your-account-password";
  52. WebMail.From = "your-email-address-here";
  53.  
  54. // Send email
  55. WebMail.Send(to: customerEmail,
  56. subject: "Help request from - " + customerName,
  57. body: customerRequest
  58. );
  59. }
  60. catch (Exception ex ) {
  61. errorMessage = ex.Message;
  62. }
  63. }
  64. <!DOCTYPE html>
  65. <html>
  66. <head>
  67. <title>Request for Assistance</title>
  68. </head>
  69. <body>
  70. <p>Sorry to hear that you are having trouble, <b>@customerName</b>.</p>
  71. @if(errorMessage == ""){
  72. <p>An email message has been sent to our customer service
  73. department regarding the following problem:</p>
  74. <p><b>@customerRequest</b></p>
  75. }
  76. else{
  77. <p><b>The email was <em>not</em> sent.</b></p>
  78. <p>Please check that the code in the ProcessRequest page has
  79. correct settings for the SMTP server name, a user name,
  80. a password, and a "from" address.
  81. </p>
  82. if(debuggingFlag){
  83. <p>The following error was reported:</p>
  84. <p><em>@errorMessage</em></p>
  85. }
  86. }
  87. </body>
  88. </html>
  89.  
  90. @using System.Net.Mail;
  91. @{
  92. if (IsPost)
  93. {
  94. var email = Request["Email"];
  95. var subject = Request["Subject"];
  96. var message = Request["Message"];
  97. using (var client = new SmtpClient())
  98. {
  99. var msg = new MailMessage();
  100. msg.To.Add(email);
  101. msg.Subject = subject;
  102. msg.Body = message;
  103. client.Send(msg);
  104. <text>The email has been successfully sent</text>
  105. }
  106. }
  107. }
  108.  
  109. <form action="" method="post">
  110. <p>Please contact us</p>
  111. <input type="text" name="email" maxlength="30" value="to@gmail.com" />
  112. <input type="text" name="subject" maxlength="30" value="Subject" />
  113. <textarea name="message" cols="30" rows="10"></textarea>
  114. <input type="submit" value="Send" class="submit" />
  115. </form>
  116.  
  117. <system.net>
  118. <mailSettings>
  119. <smtp from="youraccount@gmail.com">
  120. <network
  121. host="smtp.gmail.com"
  122. password="secret"
  123. port="587"
  124. userName="youraccount@gmail.com"
  125. enableSsl="true"
  126. />
  127. </smtp>
  128. </mailSettings>
  129. </system.net>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement