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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Store data in database as well as emailing user 2

Status
Not open for further replies.

lynxvoodoo

Technical User
Dec 28, 2002
14
GB
Hi!

I am new to asp coding and would be greatful of any help with the following.

I have created a form which once the user enters data into and click on the "submit" button, the data is stored into the database. BUT what I would like to be able to do is store the data in the databse as well as send the data via email to the user when the "submit" button is clicked.

Please can anyone advise as to how I may go abouts doing so.

Thanks,
Jeramy
 
just run your insert into the db and after with the use of a component such as CDONTS mail the values.
you can find plenty of examples of using CDONTS online with a google search. the process is fairly simple and quick to learn. main thing is to store the form values in gloabl variables in order to be able to use them for both the DB insert and the mailer process ---------------------------------------
{ str = "sleep is good for you. sleep gives you the energy you need to function";
ptr = /sleep/gi;Nstr = str.replace(ptr,"coffee");alert(Nstr); }
---------------------------------------
for the best results to your questions: FAQ333-2924

 
also it will depend on what mail components you have available to you with your server. CDONTS ASPMail ASPEmail etc.. all mailer scripts are similar in syntax with suttle differences and all have many examples online ---------------------------------------
{ str = "sleep is good for you. sleep gives you the energy you need to function";
ptr = /sleep/gi;Nstr = str.replace(ptr,"coffee");alert(Nstr); }
---------------------------------------
for the best results to your questions: FAQ333-2924

 
onpnt (Programmer) Thanks! for pointing me in the right direction. Have manager to resolve this problem.

:)
 
Try this. . .

<%@LANGUAGE=&quot;VBSCRIPT&quot;%>
<%
Dim objCDO
Set objCDO = Server.CreateObject(&quot;CDONTS.NewMail&quot;)

forename = &quot;Something&quot;
surname = &quot;Somewhere&quot;
company = &quot;Someone&quot;
jobtitle = &quot;Somehow&quot;
tel = &quot;999&quot;
Sig = Request.servervariables(&quot;LOGON_USER&quot;)

' --- connect to the database using a DSN less connection

DataSource = &quot;Driver={Microsoft Access Driver (*.mdb)}; DBQ=&quot; & Server.Mappath(&quot;../Some.mdb&quot;) & &quot;;&quot;
Set MyConn = Server.CreateObject(&quot;ADODB.Connection&quot;)
MyConn.Open DataSource


' --- Insert new users details as normal
SQLstmt = &quot;INSERT INTO ts_table (Name,forename,surname,company,jobtitle,tel)&quot;
SQLstmt = SQLstmt & &quot; VALUES ('&quot; & tel & &quot;','&quot; & forename & &quot;','&quot; & surname & &quot;','&quot; & company & &quot;','&quot; & jobtitle & &quot;','&quot; & Sig & &quot;')&quot;
MyConn.Execute(SQLstmt)

MyConn.Close
Set MyConn = nothing

' --- tell that the operation is complete
Response.write &quot;DataStored=Yes&quot;

Set DataConn = Nothing
Set objCDO = Nothing

' --- and send the email

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

objCDOMail.From = &quot;me@here.com&quot;
objCDOMail.To = &quot;me@here.com&quot;
'objCDOMail.Bcc = &quot;&quot;
objCDOMail.Subject = &quot;Subject X&quot;

' --- Set the e-mail body format (0=HTML 1=Text)
objCDOMail.BodyFormat = 0

' --- Set the mail format (0=MIME 1=Text)
objCDOMail.MailFormat = 0

myMessage = &quot;<title>Automated Timesheet System</title>&quot;
myMessage = myMessage & &quot;Some message&quot;
myMessage = myMessage & &quot;some more&quot;

objCDOMail.Body = myMessage

' --- Importance of the e-mail (0=Low, 1=Normal, 2=High)
objCDOMail.Importance = 1
objCDOMail.Send

' --- Close connections
Set objCDOMail = Nothing

%>
 
RichCraig! Thanks for responsding to my request.

Have given youself a start for taking time to help with my problem.

Regards,
Lynx
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top