Hi Vijay,
Yes, the value is valid. To check for a valid value I used:
<%
Response.Write(rsUpdate("Email"))
%>
A valid email address is displayed based on the ID value passed in the querystring.
I'm using the Dreamweaver update recordset behavior to update a database record. When I submit the form to append the update, I want to use CDOSYS to send an email to the email address stored in that record.
rsUpdate("Email") holds the value for the email.
Now, I can get the email to send, but the problem is that everytime I click the link to update, it sends an email. Even if no change is made, it will send an email. All I do is just click the update link, then it takes me to the update page passing the ID via a querystring (no changes are made) and it sends an email. I can't figure out why?
I think it has to do with where I placed the CDOSYS code. Here is a snippet of the code:
<%
Dim rsUpdate__MMColParam
rsUpdate__MMColParam = "0"
If (Request.QueryString("LoginID") <> "") Then
rsUpdate__MMColParam = Request.QueryString("LoginID")
End If
%>
<%
Dim rsUpdate
Dim rsUpdate_numRows
Set rsUpdate = Server.CreateObject("ADODB.Recordset")
rsUpdate.ActiveConnection = MM_DBConn_STRING
rsUpdate.Source = "SELECT * FROM dbo.tblLogin WHERE LoginID = " + Replace(rsUpdate__MMColParam, "'", "''") + ""
rsUpdate.CursorType = 0
rsUpdate.CursorLocation = 2
rsUpdate.LockType = 1
rsUpdate.Open()
rsUpdate_numRows = 0
sch = "http://schemas.microsoft.com/cdo/configuration/"
mailbody = "Thank you for joining my weblog. Your registration has been approved."
Set cdoConfig = CreateObject("CDO.Configuration")
With cdoConfig.Fields
.Item(sch & "sendusing") = 2 ' cdoSendUsingPort
.Item(sch & "smtpserver") = "mail.hou.wt.net"
.update
End With
Set cdoMessage = CreateObject("CDO.Message")
With cdoMessage
Set .Configuration = cdoConfig
.From = "
[email protected]"
.To = rsUpdate("Email")
.Subject = "Dwayne-Epps-Weblog-Confirmation"
.HTMLBody = mailbody
.Send
End With
Set cdoMessage = Nothing
Set cdoConfig = Nothing
%>
I tried moving the CDOSYS code within the code that generates the recordset update. Specifically, within the following code:
' execute the update
Set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
sch =
http://schemas.microsoft.com/cdo/configuration/
mailbody = "Thank you for joining my weblog. Your registration has been approved."
Set cdoConfig = CreateObject("CDO.Configuration")
With cdoConfig.Fields
.Item(sch & "sendusing") = 2 ' cdoSendUsingPort
.Item(sch & "smtpserver") = "mail.hou.wt.net"
.update
End With
Set cdoMessage = CreateObject("CDO.Message")
With cdoMessage
Set .Configuration = cdoConfig
.From = "
[email protected]"
.To = rsUpdate("Email")
.Subject = "Dwayne-Epps-Weblog-Confirmation"
.HTMLBody = mailbody
.Send
End With
Set cdoMessage = Nothing
Set cdoConfig = Nothing
If (MM_editRedirectUrl <> "") Then
Response.Redirect(MM_editRedirectUrl)
End If
End If
End If
However, when I move the code here it generates the type mismatch error.
I hope this makes sense? I can post the code for the entire page, if that is helpful.
Thanks for any help!
-Dman100-