Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_cdo thread: RE: Send e-mail on Submission Only


Message #1 by <asarkar@a...> on Wed, 1 May 2002 12:21:31 +0530
Hi Sati

Following example could help you out.

Lets assume following is the part of registration.asp
<Form method=post action=sendmail.asp>
'You can keep the fields required for registration
'prepare the emai message here
'Assuming you have a button type submit within the form tags
</form>


Write your mail sending code in the sendmail.asp. Besides sending of email
if you want to save the registration info to the datbase you should write
the code over here

Regards
Amitabh


-----Original Message-----
From: Sati Bedaysee [mailto:sbedaysee@b...]
Sent: Tuesday, April 30, 2002 5:32 PM
To: ASP CDO
Subject: [asp_cdo] Send e-mail on Submission Only


Dear All,

I have a registration page which should send an e-mail when the form has
been successfully completed and visitor hits the submit button. However,
what appears to be happening is that an e-mail is being sent as soon as the
visitor enters the page or on refresh of the page. How do I manage to get
the system to only send an e-mail on submission of the form? Below is my
code:

<%Dim CDOMail
Set CDOMail = Server.CreateObject("CDONTS.NewMail")
CDOMail.From = "info@k..."
CDOMail.To = Request("textEmail")
CDOMail.Subject = "kabin Online Questionnaire"
CDOMail.Body = "Thank you for registering with kabin." & vbcrlf&_
  "Please go to the following link and complete our online questionnaire so
we can ascertain your needs:" & vbcrlf&_
  "http://www.kabin.net/questionnaire.asp"
CDOMail.Send

Set CDOMail = nothing
%>

Regards,

Sati.

Message #2 by "Sati Bedaysee" <sbedaysee@b...> on Wed, 1 May 2002 17:55:42
Hi Amitabh

I found your suggestion very helpful, however, I have stumbled over a 
little problem. I am able to get the e-mail sent when necessary but I am 
little perplexed about getting the info stored into the database.

Can you explain further?

Thanks!

Sati.


> Hi Sati

Following example could help you out.

Lets assume following is the part of registration.asp
<Form method=post action=sendmail.asp>
'You can keep the fields required for registration
'prepare the emai message here
'Assuming you have a button type submit within the form tags
</form>


Write your mail sending code in the sendmail.asp. Besides sending of email
if you want to save the registration info to the datbase you should write
the code over here

Regards
Amitabh


-----Original Message-----
From: Sati Bedaysee [mailto:sbedaysee@b...]
Sent: Tuesday, April 30, 2002 5:32 PM
To: ASP CDO
Subject: [asp_cdo] Send e-mail on Submission Only


Dear All,

I have a registration page which should send an e-mail when the form has
been successfully completed and visitor hits the submit button. However,
what appears to be happening is that an e-mail is being sent as soon as the
visitor enters the page or on refresh of the page. How do I manage to get
the system to only send an e-mail on submission of the form? Below is my
code:

<%Dim CDOMail
Set CDOMail = Server.CreateObject("CDONTS.NewMail")
CDOMail.From = "info@k..."
CDOMail.To = Request("textEmail")
CDOMail.Subject = "kabin Online Questionnaire"
CDOMail.Body = "Thank you for registering with kabin." & vbcrlf&_
  "Please go to the following link and complete our online questionnaire so
we can ascertain your needs:" & vbcrlf&_
  "http://www.kabin.net/questionnaire.asp"
CDOMail.Send

Set CDOMail = nothing
%>

Regards,

Sati.

Message #3 by <asarkar@a...> on Thu, 2 May 2002 10:19:04 +0530
Hi Sati

Lets assume we have two ASP file, one for getting the registration info from
the customer and the other one for updating the registration info to the
database and sending a confirmation mail to the customer. Your registration
asp shall looks following.

<Form method = post action = RegistrationUpdate.asp>
<input type = text name = txtName>

'take all the input from customer here
</form>

Now, when customer clicked on submit button your 'Registrationupdate.asp'
will be processed. That should be like following

<%
Dim strSQL
dim cn as ADODB.Connection
dim rs as ADODB.RecordSet

'Assumed you have created object of ADODB.Connection and ADODB.RecordSet
varName = Request("txtName")

'Get all the values of the input field into some variable
'You can use Request("txtName") with the sql statement, this may require for
validations or data manipulation if required
strSQL = "Insert into <table name> (field name) values( " _
	& varname & ")"
rs.execute strsql

'Now from here you can write the statement for sending email
%>

It would be a better if you could write two different procedure for sending
mail and updating database and put these function in a file and call them
accordingly. In this way you will be able to reuse the code. lile following.

<%

Function UpdateRegistrationDB(varName, varAge, etc)
'Database insert/update procedure
End Function

Function Sendmail (arguments...)
'Send mail routine
End Function
%>


from your Registrationupdate.asp

<%
	UpdateResitrationDB(arguments..)
	SendMail(arguments...)
%>

Regards.
Amitabh

-----Original Message-----
From: Sati Bedaysee [mailto:sbedaysee@b...]
Sent: Wednesday, May 01, 2002 5:56 PM
To: ASP CDO
Subject: [asp_cdo] RE: Send e-mail on Submission Only


Hi Amitabh

I found your suggestion very helpful, however, I have stumbled over a
little problem. I am able to get the e-mail sent when necessary but I am
little perplexed about getting the info stored into the database.

Can you explain further?

Thanks!

Sati.


> Hi Sati

Following example could help you out.

Lets assume following is the part of registration.asp
<Form method=post action=sendmail.asp>
'You can keep the fields required for registration
'prepare the emai message here
'Assuming you have a button type submit within the form tags
</form>


Write your mail sending code in the sendmail.asp. Besides sending of email
if you want to save the registration info to the datbase you should write
the code over here

Regards
Amitabh


-----Original Message-----
From: Sati Bedaysee [mailto:sbedaysee@b...]
Sent: Tuesday, April 30, 2002 5:32 PM
To: ASP CDO
Subject: [asp_cdo] Send e-mail on Submission Only


Dear All,

I have a registration page which should send an e-mail when the form has
been successfully completed and visitor hits the submit button. However,
what appears to be happening is that an e-mail is being sent as soon as the
visitor enters the page or on refresh of the page. How do I manage to get
the system to only send an e-mail on submission of the form? Below is my
code:

<%Dim CDOMail
Set CDOMail = Server.CreateObject("CDONTS.NewMail")
CDOMail.From = "info@k..."
CDOMail.To = Request("textEmail")
CDOMail.Subject = "kabin Online Questionnaire"
CDOMail.Body = "Thank you for registering with kabin." & vbcrlf&_
  "Please go to the following link and complete our online questionnaire so
we can ascertain your needs:" & vbcrlf&_
  "http://www.kabin.net/questionnaire.asp"
CDOMail.Send

Set CDOMail = nothing
%>

Regards,

Sati.



  Return to Index