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!

Code sending 2 emails instead of one?!

Status
Not open for further replies.

LittleNFiesty

Technical User
Sep 26, 2006
46
0
0
US
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
Else
'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
rsTLAdd.AddNew

'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
rsTLAdd.Update

'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

Flds("
Flds("Flds.Update

Set ObjSendMail.Configuration=iConf
ObjSendMail.To="webmaster@someone.com"
ObjSendMail.From="someone@someone.com"
ObjSendMail.Subject=request.form("000FormInfo")

ObjSendMail.TextBody=Body
ObjSendMail.Send
Set ObjSendMail=Nothing

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

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

End If

%>
 
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.
 
The "blank" email includes:

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

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?
 
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top