Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Databases
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 9th, 2007, 01:07 AM
Authorized User
 
Join Date: Oct 2006
Location: New Delhi, Delhi, India.
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default ASP: Sending a HTML form to an email address

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


Code:
<%
Set myMail=CreateObject("CDO.Message")
myMail.Subject="Sending email with CDO"
myMail.From="mymail@mydomain.com"
myMail.To="someone@somedomain.com"
myMail.HTMLBody = "--FORM CODE HERE--" 
myMail.Send
set myMail=nothing
%>


The code for the form is as below

Code:
<form method="post" target="_blank" action="http://tulleeho.com/tastemaker/members-feedback.asp">
  <table width="70%" border="0" align="center" cellpadding="3" cellspacing="4" style="border:1px dotted #CCCCCC;">
    <tr>
      <td class="style1"><div align="right"><span class="style1">Name:</span></div></td>
      <td><input type="text" name="txtuserFirstName" value="<% =rs("userFirstName") %>"></td>
    </tr>
    <tr class="style1">
      <td colspan="2"></td>
    </tr>
    <tr>
      <td class="style1"><div align="right">Age:</div></td>
      <td><input type="text" name="txtUserAge" value="<%= datediff("yyyy",year(date),rs("userdateofBirth")) %>"></td>
    </tr>
    <tr class="style1">
      <td colspan="2"></td>
    </tr>
    <tr>
      <td class="style1"><div align="right">************:</div></td>
      <td><select name="txtuserSex">
        <option value="<% if rs("usersex") = "True" then     response.Write "1"
    if rs("usersex") = "False" then    response.Write "0"%>"><% if rs("usersex") = "True" then     response.Write "Male"
    if rs("usersex") = "False" then    response.Write "Female"%></option>
        <option value="<% if rs("usersex") = "True" then response.Write "0"
        if rs("usersex") = "False" then    response.Write "1"%>"><% if rs("usersex") = "True" then     response.Write "Female"
    if rs("usersex") = "False" then    response.Write "Male"%></option>
      </select>    </td>
    </tr>
    <tr class="style1">
      <td colspan="2"></td>
    </tr>
    <tr>
      <td class="style1"><div align="right">City:</div></td>
      <td><select name="txtUserCity">
        <option <% if rs("userCity") = "Bangalore" then response.Write "selected" %>>Bangalore</option>
        <option <% if rs("userCity") = "New Delhi" then response.Write "selected" %>>New Delhi</option>
        <option <% if rs("userCity") = "Mumbai" then response.Write "selected" %>>Mumbai</option>
        <option <% if rs("userCity") = "Hyderabad" then response.Write "selected" %>>Hyderabad</option>
        <option <% if rs("userCity") = "Pune" then response.Write "selected" %>>Pune</option>
        <option <% if rs("userCity") = "Jaipur" then response.Write "selected" %>>Jaipur</option>
      </select>    </td>
    </tr>
    <tr class="style1">
      <td colspan="2"></td>
    </tr>
    <tr>
      <td class="style1"><div align="right">Mobile No.: </div></td>
      <td><input type="text" name="txtuserPhoneNumberM" value="<% =rs("userPhoneNumberM") %>"></td>
    </tr>
    <tr class="style1">
      <td colspan="2"></td>
    </tr>
    <tr>
      <td class="style1"><div align="right">Occupation:</div></td>
      <td><input type="text" name="txtuserOccupation"></td>
    </tr>
    <tr class="style1">
      <td colspan="2"></td>
    </tr>
    <tr>
      <td valign="top" class="style1"><div align="right">Favourite Beverages:</div></td>
      <td valign="top" class="style1">
        Vodka: 
        <input type="checkbox" name="chkfav_bev" value="Vodka">
        Baileys:  <input type="checkbox" name="chkfav_bev" value="Baileys">

        Liqueur:  
        <input type="checkbox" name="chkfav_bev" value="Liqueur">
        <br>
        Tequila:  <input type="checkbox" name="chkfav_bev" value="Tequila">

        Whisky:  
        <input type="checkbox" name="chkfav_bev" value="Whisky">
        Peach Schnapps:  <input type="checkbox" name="chkfav_bev" value="Peach Schnapps">
        <br>
        Beer:  
        <input type="checkbox" name="chkfav_bev" value="Beer">
        Dark Rum:  <input type="checkbox" name="chkfav_bev" value="Dark Rum">

        White Rum:   
        <input type="checkbox" name="chkfav_bev" value="White Rum">
        Wine:  <input type="checkbox" name="chkfav_bev" value="Wine">
        Gin:  <input type="checkbox" name="chkfav_bev" value="Gin">      </td>
    </tr>
    <tr class="style1">
      <td colspan="2"></td>
    </tr>
    <tr>
      <td valign="top" class="style1"><div align="right">****tails you drink:</div></td>
      <td><input type="text" name="txtuser****tails">
        <br>
        <input type="text" name="txtuser****tails">
        <br>
        <input type="text" name="txtuser****tails">
        <br>
      <input type="text" name="txtuser****tails"></td>
    </tr>
    <tr class="style1">
      <td colspan="2"></td>
    </tr>
    <tr>
      <td valign="top" class="style1"><div align="right">Brands you purchase:</div></td>
      <td><p>
        <input type="text" name="txtuserBrands">
          <br>
        <input type="text" name="txtuserBrands">
        <br>
        <input type="text" name="txtuserBrands">
        <br>
        <input type="text" name="txtuserBrands">
        </p>
      <p>&nbsp; </p></td>
    </tr>
    <tr class="style1">
      <td colspan="2"></td>
    </tr>
    <tr>
      <td class="style1"><div align="right">Favourite bar:</div></td>
      <td><input type="text" name="txtuserFavBar"></td>
    </tr>
    <tr class="style1">
      <td colspan="2"></td>
    </tr>
    <tr>
      <td class="style1"><div align="right">Monthly spend on alcoholic beverages:</div></td>
      <td><select name="txtuserMonthlySpend">
        <option>0-500</option>
        <option>501-1000</option>
        <option>1001-1500</option>
        <option>More then 1500</option>
      </select>    </td>
    </tr>
    <tr class="style1">
      <td colspan="2"></td>
    </tr>
    <tr>
      <td class="style1"><div align="right"></div></td>
      <td><input name="subfeedback" type="submit" id="subfeedback" value="Submit"></td>
    </tr>
  </table>
  <input name="txtuserid" type="hidden" value="<%=rs("userid") %>">
</form>
-----------------------------------------------
www.chargertek.in - Cheapest WebHosting
__________________
-----------------------------------------------
www.chargertek.in - Cheapest WebHosting
Reply With Quote
  #2 (permalink)  
Old February 9th, 2007, 09:32 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

I am not sure I understand; you have your CDO object setup properly so, i guess, you are asking how to get the form data from the posted form?? Thats as simple as using Request.Form and then connect to SQL and use a recordset to get the data you need.

Just append all of your markup and data to a single string then place that string as the value for HTMLBody.

Something like
Dim sHTML

sHTML = "<B>" & Request.Form("field") & "</B>"
sHTML = sHTML & "<I>" & rs("field") & "<I>"


myMail.HTMLBody = sHTML


================================================== =========
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Reply With Quote
  #3 (permalink)  
Old February 12th, 2007, 11:50 AM
Authorized User
 
Join Date: Feb 2007
Location: Winnipeg, Manitoba, Canada.
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Wow! I might finally get to help someone.
I was having a similar problem.
Check out this website:
http://www.tele-pro.co.uk/scripts/contact_form/
What it does is generate the "proper" code for you to use.
Proper is in quotes because you do need to change a couple things,
like the success or error page.
I used it and it works great!
I should note you don't need to use the form code they give you. I just used the form I created. When I was to enter the fields, I just used the names in my existing form.
When that was done, it generated both Form and submit code.
All I did was copy to submit code to a submit page.
Try it out. Let me know if it works!
Good Luck!

Now is the only thing that's real.
Reply With Quote
  #4 (permalink)  
Old February 19th, 2007, 01:17 AM
Authorized User
 
Join Date: Oct 2006
Location: New Delhi, Delhi, India.
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by dparsons
 I am not sure I understand; you have your CDO object setup properly so, i guess, you are asking how to get the form data from the posted form?? Thats as simple as using Request.Form and then connect to SQL and use a recordset to get the data you need.

Just append all of your markup and data to a single string then place that string as the value for HTMLBody.

Something like
Dim sHTML

sHTML = "<B>" & Request.Form("field") & "</B>"
sHTML = sHTML & "<I>" & rs("field") & "<I>"


myMail.HTMLBody = sHTML


================================================== =========
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Hi,

Thanx for the reply, have a question though, what if I ahve to place some "if else" conditions within sHTML... like

sHTML = "<B>" & if Request.Form("field") = 1 then response.write "True" & "</B>"

The above code does not work, any idea?


Thanx



-----------------------------------------------
www.chargertek.in - Cheapest WebHosting
Reply With Quote
  #5 (permalink)  
Old February 19th, 2007, 05:25 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

You have your logic backwards. First you wouldnt response.write anything, you would do something like:

if Request.Form("field") = 1 then
  sHtml = "<b>True</b>"
else
  sHtml = "<b>False</b>"
end if

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html

Discussion:
http://p2p.wrox.com/topic.asp?TOPIC_ID=56429
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Retain text in html form asp email b00gieman Classic ASP Basics 0 August 31st, 2007 04:30 AM
Issue sending HTML file as attachment in EMail kdhawan_forum VB Components 0 April 8th, 2005 02:02 PM
Sending email thru Outlook Exp. from VB with html rambhias Beginning VB 6 4 November 22nd, 2004 03:12 AM



All times are GMT -4. The time now is 06:24 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.