944,052 Members | Top Members by Rank

Ad:
  • ASP Discussion Thread
  • Unsolved
  • Views: 4251
  • ASP RSS
Feb 9th, 2007
0

ASP: Sending a HTML form to an email address

Expand Post »
Hi,

I am using CDONTs for sending email using ASP. I need to send a HTML form that takes values from a MS SQL Server database. How do I send this big code of form using ASP?

I am using the following code to send the email


ASP Syntax (Toggle Plain Text)
  1. <%
  2. Set myMail=CreateObject("CDO.Message")
  3. myMail.Subject="Sending email with CDO"
  4. myMail.From="mymail@mydomain.com"
  5. myMail.To="someone@somedomain.com"
  6. myMail.HTMLBody = "--FORM CODE HERE--"
  7. myMail.Send
  8. set myMail=nothing
  9. %>



The code for the form is as below

ASP Syntax (Toggle Plain Text)
  1. <form method="post" target="_blank" action="http://tulleeho.com/tastemaker/members-feedback.asp">
  2. <table width="70%" border="0" align="center" cellpadding="3" cellspacing="4" style="border:1px dotted #CCCCCC;">
  3. <tr>
  4. <td class="style1"><div align="right"><span class="style1">Name:</span></div></td>
  5. <td><input type="text" name="txtuserFirstName" value="<% =rs("userFirstName") %>"></td>
  6. </tr>
  7. <tr class="style1">
  8. <td colspan="2"><HR align="right" style="border:1px dotted #CCCCCC;"></td>
  9. </tr>
  10. <tr>
  11. <td class="style1"><div align="right">Age:</div></td>
  12. <td><input type="text" name="txtUserAge" value="<%= datediff("yyyy",year(date),rs("userdateofBirth")) %>"></td>
  13. </tr>
  14. <tr class="style1">
  15. <td colspan="2"><HR align="right" style="border:1px dotted #CCCCCC;"></td>
  16. </tr>
  17. <tr>
  18. <td class="style1"><div align="right">Sex:</div></td>
  19. <td><select name="txtuserSex">
  20. <option value="<% if rs("usersex") = "True" then response.Write "1"
  21. if rs("usersex") = "False" then response.Write "0"%>"><% if rs("usersex") = "True" then response.Write "Male"
  22. if rs("usersex") = "False" then response.Write "Female"%></option>
  23. <option value="<% if rs("usersex") = "True" then response.Write "0"
  24. if rs("usersex") = "False" then response.Write "1"%>"><% if rs("usersex") = "True" then response.Write "Female"
  25. if rs("usersex") = "False" then response.Write "Male"%></option>
  26. </select> </td>
  27. </tr>
  28. <tr class="style1">
  29. <td colspan="2"><HR align="right" style="border:1px dotted #CCCCCC;"></td>
  30. </tr>
  31. <tr>
  32. <td class="style1"><div align="right">City:</div></td>
  33. <td><select name="txtUserCity">
  34. <option <% if rs("userCity") = "Bangalore" then response.Write "selected" %>>Bangalore</option>
  35. <option <% if rs("userCity") = "New Delhi" then response.Write "selected" %>>New Delhi</option>
  36. <option <% if rs("userCity") = "Mumbai" then response.Write "selected" %>>Mumbai</option>
  37. <option <% if rs("userCity") = "Hyderabad" then response.Write "selected" %>>Hyderabad</option>
  38. <option <% if rs("userCity") = "Pune" then response.Write "selected" %>>Pune</option>
  39. <option <% if rs("userCity") = "Jaipur" then response.Write "selected" %>>Jaipur</option>
  40. </select> </td>
  41. </tr>
  42. <tr class="style1">
  43. <td colspan="2"><HR align="right" style="border:1px dotted #CCCCCC;"></td>
  44. </tr>
  45. <tr>
  46. <td class="style1"><div align="right">Mobile No.: </div></td>
  47. <td><input type="text" name="txtuserPhoneNumberM" value="<% =rs("userPhoneNumberM") %>"></td>
  48. </tr>
  49. <tr class="style1">
  50. <td colspan="2"><HR align="right" style="border:1px dotted #CCCCCC;"></td>
  51. </tr>
  52. <tr>
  53. <td class="style1"><div align="right">Occupation:</div></td>
  54. <td><input type="text" name="txtuserOccupation"></td>
  55. </tr>
  56. <tr class="style1">
  57. <td colspan="2"><HR align="right" style="border:1px dotted #CCCCCC;"></td>
  58. </tr>
  59. <tr>
  60. <td valign="top" class="style1"><div align="right">Favourite Beverages:</div></td>
  61. <td valign="top" class="style1">
  62. Vodka:
  63. <input type="checkbox" name="chkfav_bev" value="Vodka">
  64. Baileys: <input type="checkbox" name="chkfav_bev" value="Baileys">
  65.  
  66. Liqueur:
  67. <input type="checkbox" name="chkfav_bev" value="Liqueur">
  68. <br>
  69. Tequila: <input type="checkbox" name="chkfav_bev" value="Tequila">
  70.  
  71. Whisky:
  72. <input type="checkbox" name="chkfav_bev" value="Whisky">
  73. Peach Schnapps: <input type="checkbox" name="chkfav_bev" value="Peach Schnapps">
  74. <br>
  75. Beer:
  76. <input type="checkbox" name="chkfav_bev" value="Beer">
  77. Dark Rum: <input type="checkbox" name="chkfav_bev" value="Dark Rum">
  78.  
  79. White Rum:
  80. <input type="checkbox" name="chkfav_bev" value="White Rum">
  81. Wine: <input type="checkbox" name="chkfav_bev" value="Wine">
  82. Gin: <input type="checkbox" name="chkfav_bev" value="Gin"> </td>
  83. </tr>
  84. <tr class="style1">
  85. <td colspan="2"><HR align="right" style="border:1px dotted #CCCCCC;"></td>
  86. </tr>
  87. <tr>
  88. <td valign="top" class="style1"><div align="right">****tails you drink:</div></td>
  89. <td><input type="text" name="txtuser****tails">
  90. <br>
  91. <input type="text" name="txtuser****tails">
  92. <br>
  93. <input type="text" name="txtuser****tails">
  94. <br>
  95. <input type="text" name="txtuser****tails"></td>
  96. </tr>
  97. <tr class="style1">
  98. <td colspan="2"><HR align="right" style="border:1px dotted #CCCCCC;"></td>
  99. </tr>
  100. <tr>
  101. <td valign="top" class="style1"><div align="right">Brands you purchase:</div></td>
  102. <td><p>
  103. <input type="text" name="txtuserBrands">
  104. <br>
  105. <input type="text" name="txtuserBrands">
  106. <br>
  107. <input type="text" name="txtuserBrands">
  108. <br>
  109. <input type="text" name="txtuserBrands">
  110. </p>
  111. <p>&nbsp; </p></td>
  112. </tr>
  113. <tr class="style1">
  114. <td colspan="2"><HR align="right" style="border:1px dotted #CCCCCC;"></td>
  115. </tr>
  116. <tr>
  117. <td class="style1"><div align="right">Favourite bar:</div></td>
  118. <td><input type="text" name="txtuserFavBar"></td>
  119. </tr>
  120. <tr class="style1">
  121. <td colspan="2"><HR align="right" style="border:1px dotted #CCCCCC;"></td>
  122. </tr>
  123. <tr>
  124. <td class="style1"><div align="right">Monthly spend on alcoholic beverages:</div></td>
  125. <td><select name="txtuserMonthlySpend">
  126. <option>0-500</option>
  127. <option>501-1000</option>
  128. <option>1001-1500</option>
  129. <option>More then 1500</option>
  130. </select> </td>
  131. </tr>
  132. <tr class="style1">
  133. <td colspan="2"><HR align="right" style="border:1px dotted #CCCCCC;"></td>
  134. </tr>
  135. <tr>
  136. <td class="style1"><div align="right"></div></td>
  137. <td><input name="subfeedback" type="submit" id="subfeedback" value="Submit"></td>
  138. </tr>
  139. </table>
  140. <input name="txtuserid" type="hidden" value="<%=rs("userid") %>">
  141. </form>
Similar Threads
Reputation Points: 58
Solved Threads: 1
Posting Whiz in Training
cancer10 is offline Offline
234 posts
since Dec 2004
Feb 16th, 2007
0

Re: ASP: Sending a HTML form to an email address

To display all values, simply use this code:

For each i in Request.Form
myMail.HTMLBody = myMail.HTMLBody & i & ": " & request.form(i) & "<br>"
next
Reputation Points: 11
Solved Threads: 7
Junior Poster in Training
Baradaran is offline Offline
88 posts
since Feb 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP Forum Timeline: verify page not finding random records
Next Thread in ASP Forum Timeline: How to make a paging?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC