Print Page | Close Window

Mailing form resultsand updating a dbase

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: General Discussion
Forum Description: General discussion and chat on any topic.
URL: https://forums.webwiz.net/forum_posts.asp?TID=4963
Printed Date: 29 March 2026 at 3:41pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Mailing form resultsand updating a dbase
Posted By: johnnie
Subject: Mailing form resultsand updating a dbase
Date Posted: 12 August 2003 at 12:19pm
Any script that does the following........mailing web form results and at the same time, updating a SQL database



Replies:
Posted By: faubo
Date Posted: 12 August 2003 at 12:33pm

you mean populate your database and send an e-mail at the same time?

if this is what you are looking for... itīs really easy, just mix the two codes and you will make it. Put all the info in variables, use it to update your db fields and after that (dont forget to close the db connections) you use them again to fill your e-mail fields.



-------------
http://www.conhecerparaconservar.org - I don't know how to make you click here


Posted By: johnnie
Date Posted: 13 August 2003 at 7:58am
Great faubo....but please can't i get any sample code to compare it to my situation?


Posted By: Misty
Date Posted: 13 August 2003 at 6:47pm

Johnnie,

I will give you some sample code. But this is for an Access database. It should not be hard to modify the code to work with SQL Server Database. I hope this helps.

Here's some sample code:

'Declare constants for a recordset that allows adding records

Const adLockOptimistic = 3

Const adOpenDynamic = 2

dim sqlString

dim connectionString, databaseName, Path

'Set connection details (add your connection details here)

'Set the sqlString (add your sql statement here)

'Create the recordset

set rs = Server.CreateObject("ADODB.Recordset")

rs.Open sqlString, connectionString, adOpenDynamic, adLockOptimistic

dim FirstName, LastName, Name

'Get values for new record from the form that the user submitted on the previous web page 

FirstName = Request.Form("txtFirstName")

LastName = Request.Form("txtLastName")

Name = firstName & " " & lastName

rs.AddNew

rs("FirstName") = FirstName

rs("LastName") = LastName

'Fill in recordset field values, while converting all

'empty strings to Null values

rs("FirstName") = ConvertEmptyToNull(FirstName)

rs("LastName") = ConvertEmptyToNull(LastName)

'Save the record to the database for the first recordset

rs.Update

 

dim MyMail

Set MyMail = Server.CreateObject("CDONTS.NewMail")

EmailBody = "Name: " & Name & ""

MyMail.From = Name & "<" & Email & ">"

MyMail.To = "info@youremailaddress.com"

MyMail.Subject = "Hello"

MyMail.Body = EmailBody

MyMail.Send

set MyMail = Nothing

rs.Close 

Set rs = Nothing



Posted By: johnnie
Date Posted: 14 August 2003 at 1:37am
thanx Misty.....will give it a try......and get in touch



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net