Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Code sending 2 emails instead of one?!

Code sending 2 emails instead of one?!

Code sending 2 emails instead of one?!

I can't figure out why the below code is sending two emails. The code is to add a new record to an access db and send an email notifying that a new record was created, but instead of one email sent I always get 2, one blank and one with the correct info. I know it's something obvious but I just can't see it.
Here is the code:

Dim refURL
refURL = Request.ServerVariables("HTTP_REFERER")

If (refURL = "") Then
'Do nothing because the page has no referer
'Process the page, refURL is not empty

'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsTLAdd 'Holds the recordset for the records the be updated
Dim strSQL 'Holds the SQL query to query the database
Dim Body 'Email Body

'Create an ADO connection object
Set adoCon = Server.CreateObject("ADODB.Connection")

'Set an active connection to the Connection object using a DNS-less connection
adoCon.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=XXXXXXXXX"

'Create an ADO recordset object
Set rsTLAdd = Server.CreateObject("ADODB.Recordset")

'Initialise the strSQL variable with a SQL statement to query the database
strSQL = "SELECT Tbl_RegistrationList.* FROM Tbl_RegistrationList;"

'Set the cursor type we are using so we can navigate through the recordset
rsTLAdd.CursorType = 2

'Set the lock type so the the recrod is loced by ADO when it is updated
rsTLAdd.LockType = 3

'Open the recordset with SQL query
rsTLAdd.Open strSQL, adoCon

'Tell the recordset we are adding a new record to it

'Update record to the recordset
rsTLAdd.Fields("Name") = Request.Form("Name")
rsTLAdd.Fields("Company") = Request.Form("Company")
rsTLAdd.Fields("Address1") = Request.Form("Address1")
rsTLAdd.Fields("Address2") = Request.Form("Address2")
rsTLAdd.Fields("City") = Request.Form("City")
rsTLAdd.Fields("State") = Request.Form("State")
rsTLAdd.Fields("ZipCode") = Request.Form("Zip_Code")
rsTLAdd.Fields("Country") = Request.Form("Country")
rsTLAdd.Fields("Phone") = Request.Form("Phone")
rsTLAdd.Fields("Email") = Request.Form("Email")
rsTLAdd.Fields("RegistrationDate") = CDate(FormatDateTime(Now,2))

'Tell the recordset we are updating record

'Email coding:

'current date and IP address for email
datCurrDate = Now
StrReferer = Request.ServerVariables ("HTTP_REFERER")

Body = Body & "Registered User:" & vbCrLf & Request.Form("Email") & vbCrLf & Request.Form("Name") & vbCrLf & Request.Form("Company") & vbCrLf & Request.Form("Address1")& vbCrLf & Request.Form("Address2") & vbCrLf & Request.Form("City")& vbCrLf & Request.Form("State") & vbCrLf & Request.Form("ZipCode") & vbCrLf & Request.Form("Country") & vbCrLf & vbCrLf

Body = Body & "The Above was submitted via your online form: " & Request.Form("000FormInfo") & vbCrLf & "At: " & strReferer & vbCrLf & "On: " & datCurrDate & vbCrLf & "By: " & Request.ServerVariables("REMOTE_ADDR") & vbCrLf & vbCrLf

Dim ObjSendMail
Dim iConf
Dim Flds

Set ObjSendMail=Server.CreateObject("CDO.Message")
Set iConf=CreateObject("CDO.Configuration")
Set Flds=iConf.Fields



Set ObjSendMail.Configuration=iConf

Set ObjSendMail=Nothing

'Reset server objects
Set rsTLAdd = Nothing
Set adoCon = Nothing

'Redirect to page
Response.Redirect "../Page.asp"

End If


RE: Code sending 2 emails instead of one?!

When you say "blank", do you mean truly blank, or are the words "Registered User:" and "The Above was submitted via your online form: " included, with no form values? Nothing here indicates that two emails would be sent, so somewhere else in your code you may be executing the above block of code.

RE: Code sending 2 emails instead of one?!

The "blank" email includes:

"The Following was submitted via your online form:
At: page.asp
On: 3/5/2013 3:41:26 PM

And the second email includes the registered user information along with the above, like it's suppose to.

Any ideas base off this additional information?

RE: Code sending 2 emails instead of one?!

Well, the text "The Following was submitted via your online form" is not in the code you posted, so the extra email is being generated elsewhere. Googling that text seems to indicate it's from formmail.asp from voyagerhosting.net, whatever that is. Perhaps these clues will help you solve the problem.

RE: Code sending 2 emails instead of one?!

thank you!!!!! I found it!!!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close