Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Email and database registration from forms

Status
Not open for further replies.

ALILL

Technical User
Mar 29, 2002
6
0
0
NL
Is it possible to register details from a form in access while at the same time send the details as an e mail.Have managed to do both but not at the same time.
 
Why not just do one, and then do the other? Just one after the other. ________________________________________
Ignorance is a beautiful thing:
You don't know what you can't do...
 
When you say, "I have managed to do both but not at the same time" I assume your have entered the form's data into a database them pulled the recordset and emailed it.

Now, simply submit your form's imformation to the email processing page then enter it to the database.
[sup]
[sup]
Got ASP Error(s)? = [/sup]
 
Have finally found the answer after a lot of searching,this code will send an e mail and enter the details in access on submit.

<html>
<head>

<title>Input Form</title>
</head>
<body>
<%
if request.form(&quot;Submit&quot;)<> &quot;Submit&quot; then
%>
<form action=&quot;rfi.asp&quot; method=&quot;POST&quot;>
<table width=&quot;483&quot;>
<tr>
<td align=&quot;right&quot; width=&quot;104&quot;>Type of Input</td>
<td width=&quot;369&quot;> <select size=&quot;1&quot; name=&quot;Type&quot; tabindex=&quot;1&quot;>
<option value=&quot;Comment&quot; selected>Comment</option>
<option value=&quot;Suggestion&quot;>Suggestion</option>
<option value=&quot;Question&quot;>Question</option>
</select></td>
</tr>
<tr>
<td align=&quot;right&quot; width=&quot;104&quot;>Area</td>
<td width=&quot;369&quot;> <select size=&quot;1&quot; name=&quot;Area&quot; tabindex=&quot;2&quot;>
<option value=&quot;Advertising&quot; selected>Advertising</option>
<option value=&quot;Programs&quot;>Programs</option>
<option value=&quot;Sales&quot;>Sales</option>
<option value=&quot;Support&quot;>Support</option>
<option value=&quot;Web Site&quot;>Web Site</option>
</select></td>
</tr>
<tr>
<td align=&quot;right&quot; width=&quot;104&quot;>First Name</td>
<td width=&quot;369&quot;>
<input name=&quot;FirstName&quot; type=&quot;text&quot; size=&quot;20&quot; tabindex=&quot;3&quot;></td>
</tr>
<tr>
<td align=&quot;right&quot; width=&quot;104&quot;>Last Name</td>
<td width=&quot;369&quot;>
<input name=&quot;LastName&quot; type=&quot;text&quot; size=&quot;20&quot; tabindex=&quot;4&quot;></td>
</tr>
<tr>
<td align=&quot;right&quot; width=&quot;104&quot;>email address</td>
<td width=&quot;369&quot;>
<input name=&quot;email&quot; type=&quot;text&quot; size=&quot;50&quot; tabindex=&quot;5&quot;></td>
</tr>
<tr>
<td align=&quot;right&quot; valign=&quot;top&quot; width=&quot;104&quot;>Comments</td>
<td width=&quot;369&quot;>
<textarea rows=&quot;5&quot; name=&quot;Comments&quot; cols=&quot;42&quot; tabindex=&quot;7&quot;></textarea></td>
</tr>
<tr>
<td align=&quot;right&quot; width=&quot;104&quot;><input name=&quot;Submit&quot; type=submit value=&quot;Submit&quot;></td>
<td width=&quot;369&quot;><input name=&quot;reset&quot; type=reset value=&quot;Reset&quot;></td>
</tr>
</table>
</form>
<%
else

strType=Request.form(&quot;Type&quot;)
strArea=Request.form(&quot;Area&quot;)
strFirstName=Request.form(&quot;FirstName&quot;)
strLastName=Request.form(&quot;LastName&quot;)
stremail=Request.form(&quot;email&quot;)
strDate=Date
strComments=Request.form(&quot;Comments&quot;)

Set objConn = Server.CreateObject(&quot;ADODB.Connection&quot;)
ConnectionString=&quot;DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=&quot; & Server.MapPath(&quot;comments.mdb&quot;)
objConn.Open ConnectionString

sqlQuery = &quot;SELECT * FROM Comments&quot;
Set objRS = Server.CreateObject(&quot;ADODB.Recordset&quot;)
objRS.Open sqlQuery, objConn, 1, 2

objRS.AddNew
objRS(&quot;Type&quot;)=strType
objRS(&quot;Area&quot;)=strArea
objRS(&quot;FirstName&quot;)=strFirstName
objRS(&quot;LastName&quot;)=strLastName
objRS(&quot;email&quot;)=stremail
objRS(&quot;SubmitDate&quot;)=strDate
objRS(&quot;comments&quot;)=strcomments

objRS.Update
objRS.Close
Set objRS = Nothing

strBody = &quot;Type ------> &quot; & strType & chr(10) & chr(13)
strBody=strBody & &quot;Area ------> &quot; & strArea & chr(10) & chr(13)
strBody=strBody & &quot;Name ------> &quot; & strFirstName & &quot; &quot; & strLastName & chr(10) & chr(13)
strBody=strBody & &quot;email -----> &quot; & stremail & chr(10) & chr(13)
strBody=strBody & &quot;Comments --> &quot; & strComments & chr(10) & chr(13)
strBody=strBody & &quot;Date ------> &quot; & strDate & chr(10) & chr(13)
strBody=strBody & &quot;--------------- &quot; & chr(10) & chr(13)

Dim objCDO

Set objCDO = Server.CreateObject(&quot;CDONTS.NewMail&quot;)

objCDO.From = &quot;youremail@yourwebsite.com&quot;
objCDO.To = &quot;youremail@yourwebsite.com&quot;
objCDO.Subject = &quot;Comments, Suggestions & Questions&quot;
objCDO.Body = strBody
objCDO.BodyFormat = 1
objCDO.MailFormat = 1
objCDO.Send

Set objCDO = Server.CreateObject(&quot;CDONTS.NewMail&quot;)

objCDO.From = &quot;youremail@yourwebsite.com&quot;
objCDO.To = stremail
objCDO.Subject = &quot;Comments, Suggestions & Questions&quot;
objCDO.Body = strBody
objCDO.BodyFormat = 1
objCDO.MailFormat = 1
objCDO.Send

Response.Write &quot;Record Added Succesfully<BR><BR>&quot;
Response.Write strFirstName & &quot; &quot; & strLastName
Response.Write &quot;, Thanks for the &quot; & strType
Response.Write &quot; about our &quot; & strArea



end if
%>

</body>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top