Forums
This topic is locked
CDONT to Access and recipient? Help!
Posted 14 Sep 2001 21:30:24
1
has voted
14 Sep 2001 21:30:24 Zain Magsi posted:
How can send an email to a recipient and a access database with CDONTS?Zain
Zain Magsi
Replies
Replied 14 Sep 2001 23:39:32
14 Sep 2001 23:39:32 Owen Eastwick replied:
You can't Email a database.
You can collect input from a Form, Email the results and use the same input to update a database table.
Regards
Owen.
Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
You can collect input from a Form, Email the results and use the same input to update a database table.
Regards
Owen.
Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
Replied 19 Sep 2001 01:02:09
19 Sep 2001 01:02:09 Owen Eastwick replied:
Zain, here is some code from the new user registration page for a site.
<pre id=code><font face=courier size=2 id=code>
<%
' *** Insert Record: set variables
If (CStr(Request("MM_insert") <> "" Then
'To Correct Server Time in U.S.A 6 hours behind UK time
ServerTime = Now()
CorrectTime = DateAdd("h",6,ServerTime)
MessageTo = Request("Email Address"
FirstName = Request("First Name"
LastName = Request("Last Name"
Username = Request("Username"
Password = Request("Password"
ContactName = Request("Contact Name"
EmailAddress = Request("Email Address"
DayTel = Request("Day Tel"
EveTel = Request("Evening Tel"
Mobile = Request("Mobile"
If DayTel = "" Then
DayTel = "No Number Provided"
End If
If EveTel = "" Then
EveTel = "No Number Provided"
End If
If Mobile = "" Then
Mobile = "No Number Provided"
End If
'The header/footer for the email
Header1 = "Hello "& FirstName &", many thanks for registering with GBsounds"
mail_Body = Header1 & vbCrLf & vbCrLf
mail_Body = mail_Body & "First Name: " & FirstName & vbCrLf
mail_Body = mail_Body & "Last Name: " & LastName & vbCrLf
mail_Body = mail_Body & "Username: " & Username & vbCrLf
mail_Body = mail_Body & "Password: " & Password & vbCrLf
mail_Body = mail_Body & "Contact Name: " & ContactName & vbCrLf
mail_Body = mail_Body & "Email Address: " & EmailAddress & vbCrLf
mail_Body = mail_Body & "Daytime Telephone: " & DayTel & vbCrLf
mail_Body = mail_Body & "Evening Telephone: " & EveTel & vbCrLf
mail_Body = mail_Body & "Mobile: " & Mobile & vbCrLf
'Create the mail object and send the mail
Dim objCDO
Set objCDO = Server.CreateObject("CDONTS.NewMail"
objCDO.To = MessageTo
objCDO.From = " "
objCDO.Subject = "GBsounds Registration Details"
objCDO.Body = mail_Body
objCDO.Send
Set objCDO = Nothing
'Then Insert the new records
MM_editConnection = MM_GBsounds2OLE_STRING
MM_editTable = "users"
MM_editRedirectUrl = "regthanks.asp"
MM_fieldsStr = "First Name|value|Last Name|value|Username|value|Password|value|Contact Name|value|Email Address|value|Day Tel|value|Evening Tel|value|Mobile|value|AccessLevel|value"
MM_columnsStr = "FirstName|',none,''|LastName|',none,''|UserName|',none,''|UserPassword|',none,''|ContactName|',none,''|Email|',none,''|DayTel|',none,''|EveTel|',none,''|Mobile|',none,''|AccessLevel|none,none,NULL"
' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|"
MM_columns = Split(MM_columnsStr, "|"
' set the form values
For i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(i+1) = CStr(Request.Form(MM_fields(i)))
Next
' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And Request.QueryString <> "" Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "" Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If
End If
%>
<%
' *** Insert Record: construct a sql insert statement and execute it
If (CStr(Request("MM_insert") <> "" Then
Session("MM_Username" = cStr(Request("Username")
' create the sql insert statement
MM_tableValues = ""
MM_dbValues = ""
For i = LBound(MM_fields) To UBound(MM_fields) Step 2
FormVal = MM_fields(i+1)
MM_typeArray = Split(MM_columns(i+1),","
Delim = MM_typeArray(0)
If (Delim = "none" Then Delim = ""
AltVal = MM_typeArray(1)
If (AltVal = "none" Then AltVal = ""
EmptyVal = MM_typeArray(2)
If (EmptyVal = "none" Then EmptyVal = ""
If (FormVal = "" Then
FormVal = EmptyVal
Else
If (AltVal <> "" Then
FormVal = AltVal
ElseIf (Delim = "'" Then ' escape quotes
FormVal = "'" & Replace(FormVal,"'","''" & "'"
Else
FormVal = Delim + FormVal + Delim
End If
End If
If (i <> LBound(MM_fields)) Then
MM_tableValues = MM_tableValues & ","
MM_dbValues = MM_dbValues & ","
End if
MM_tableValues = MM_tableValues & MM_columns(i)
MM_dbValues = MM_dbValues & FormVal
Next
MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & " values (" & MM_dbValues & ""
If (Not MM_abortEdit) Then
' execute the insert
Set MM_editCmd = Server.CreateObject("ADODB.Command"
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
If (MM_editRedirectUrl <> "" Then
Response.Redirect(MM_editRedirectUrl)
End If
End If
End If
%></font id=code></pre id=code>
Basically set up the insert record behaviour, then put your CDONTS Email code after the <pre id=code><font face=courier size=2 id=code>If (CStr(Request("MM_insert") <> "" Then</font id=code></pre id=code>Line.
Regards
Owen.
Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
Edited by - oeastwick on 09/19/2001 01:04:39
Edited by - oeastwick on 09/19/2001 01:05:37
<pre id=code><font face=courier size=2 id=code>
<%
' *** Insert Record: set variables
If (CStr(Request("MM_insert") <> "" Then
'To Correct Server Time in U.S.A 6 hours behind UK time
ServerTime = Now()
CorrectTime = DateAdd("h",6,ServerTime)
MessageTo = Request("Email Address"
FirstName = Request("First Name"
LastName = Request("Last Name"
Username = Request("Username"
Password = Request("Password"
ContactName = Request("Contact Name"
EmailAddress = Request("Email Address"
DayTel = Request("Day Tel"
EveTel = Request("Evening Tel"
Mobile = Request("Mobile"
If DayTel = "" Then
DayTel = "No Number Provided"
End If
If EveTel = "" Then
EveTel = "No Number Provided"
End If
If Mobile = "" Then
Mobile = "No Number Provided"
End If
'The header/footer for the email
Header1 = "Hello "& FirstName &", many thanks for registering with GBsounds"
mail_Body = Header1 & vbCrLf & vbCrLf
mail_Body = mail_Body & "First Name: " & FirstName & vbCrLf
mail_Body = mail_Body & "Last Name: " & LastName & vbCrLf
mail_Body = mail_Body & "Username: " & Username & vbCrLf
mail_Body = mail_Body & "Password: " & Password & vbCrLf
mail_Body = mail_Body & "Contact Name: " & ContactName & vbCrLf
mail_Body = mail_Body & "Email Address: " & EmailAddress & vbCrLf
mail_Body = mail_Body & "Daytime Telephone: " & DayTel & vbCrLf
mail_Body = mail_Body & "Evening Telephone: " & EveTel & vbCrLf
mail_Body = mail_Body & "Mobile: " & Mobile & vbCrLf
'Create the mail object and send the mail
Dim objCDO
Set objCDO = Server.CreateObject("CDONTS.NewMail"
objCDO.To = MessageTo
objCDO.From = " "
objCDO.Subject = "GBsounds Registration Details"
objCDO.Body = mail_Body
objCDO.Send
Set objCDO = Nothing
'Then Insert the new records
MM_editConnection = MM_GBsounds2OLE_STRING
MM_editTable = "users"
MM_editRedirectUrl = "regthanks.asp"
MM_fieldsStr = "First Name|value|Last Name|value|Username|value|Password|value|Contact Name|value|Email Address|value|Day Tel|value|Evening Tel|value|Mobile|value|AccessLevel|value"
MM_columnsStr = "FirstName|',none,''|LastName|',none,''|UserName|',none,''|UserPassword|',none,''|ContactName|',none,''|Email|',none,''|DayTel|',none,''|EveTel|',none,''|Mobile|',none,''|AccessLevel|none,none,NULL"
' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|"
MM_columns = Split(MM_columnsStr, "|"
' set the form values
For i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(i+1) = CStr(Request.Form(MM_fields(i)))
Next
' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And Request.QueryString <> "" Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "" Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If
End If
%>
<%
' *** Insert Record: construct a sql insert statement and execute it
If (CStr(Request("MM_insert") <> "" Then
Session("MM_Username" = cStr(Request("Username")
' create the sql insert statement
MM_tableValues = ""
MM_dbValues = ""
For i = LBound(MM_fields) To UBound(MM_fields) Step 2
FormVal = MM_fields(i+1)
MM_typeArray = Split(MM_columns(i+1),","
Delim = MM_typeArray(0)
If (Delim = "none" Then Delim = ""
AltVal = MM_typeArray(1)
If (AltVal = "none" Then AltVal = ""
EmptyVal = MM_typeArray(2)
If (EmptyVal = "none" Then EmptyVal = ""
If (FormVal = "" Then
FormVal = EmptyVal
Else
If (AltVal <> "" Then
FormVal = AltVal
ElseIf (Delim = "'" Then ' escape quotes
FormVal = "'" & Replace(FormVal,"'","''" & "'"
Else
FormVal = Delim + FormVal + Delim
End If
End If
If (i <> LBound(MM_fields)) Then
MM_tableValues = MM_tableValues & ","
MM_dbValues = MM_dbValues & ","
End if
MM_tableValues = MM_tableValues & MM_columns(i)
MM_dbValues = MM_dbValues & FormVal
Next
MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & " values (" & MM_dbValues & ""
If (Not MM_abortEdit) Then
' execute the insert
Set MM_editCmd = Server.CreateObject("ADODB.Command"
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
If (MM_editRedirectUrl <> "" Then
Response.Redirect(MM_editRedirectUrl)
End If
End If
End If
%></font id=code></pre id=code>
Basically set up the insert record behaviour, then put your CDONTS Email code after the <pre id=code><font face=courier size=2 id=code>If (CStr(Request("MM_insert") <> "" Then</font id=code></pre id=code>Line.
Regards
Owen.
Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
Edited by - oeastwick on 09/19/2001 01:04:39
Edited by - oeastwick on 09/19/2001 01:05:37
Replied 19 Sep 2001 05:01:13
19 Sep 2001 05:01:13 Zain Magsi replied:
Awesome! Thank you so much <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>
Zain
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Zain, here is some code from the new user registration page for a site.
<pre id=code><font face=courier size=2 id=code>
<%
' *** Insert Record: set variables
If (CStr(Request("MM_insert") <> "" Then
'To Correct Server Time in U.S.A 6 hours behind UK time
ServerTime = Now()
CorrectTime = DateAdd("h",6,ServerTime)
MessageTo = Request("Email Address"
FirstName = Request("First Name"
LastName = Request("Last Name"
Username = Request("Username"
Password = Request("Password"
ContactName = Request("Contact Name"
EmailAddress = Request("Email Address"
DayTel = Request("Day Tel"
EveTel = Request("Evening Tel"
Mobile = Request("Mobile"
If DayTel = "" Then
DayTel = "No Number Provided"
End If
If EveTel = "" Then
EveTel = "No Number Provided"
End If
If Mobile = "" Then
Mobile = "No Number Provided"
End If
'The header/footer for the email
Header1 = "Hello "& FirstName &", many thanks for registering with GBsounds"
mail_Body = Header1 & vbCrLf & vbCrLf
mail_Body = mail_Body & "First Name: " & FirstName & vbCrLf
mail_Body = mail_Body & "Last Name: " & LastName & vbCrLf
mail_Body = mail_Body & "Username: " & Username & vbCrLf
mail_Body = mail_Body & "Password: " & Password & vbCrLf
mail_Body = mail_Body & "Contact Name: " & ContactName & vbCrLf
mail_Body = mail_Body & "Email Address: " & EmailAddress & vbCrLf
mail_Body = mail_Body & "Daytime Telephone: " & DayTel & vbCrLf
mail_Body = mail_Body & "Evening Telephone: " & EveTel & vbCrLf
mail_Body = mail_Body & "Mobile: " & Mobile & vbCrLf
'Create the mail object and send the mail
Dim objCDO
Set objCDO = Server.CreateObject("CDONTS.NewMail"
objCDO.To = MessageTo
objCDO.From = " "
objCDO.Subject = "GBsounds Registration Details"
objCDO.Body = mail_Body
objCDO.Send
Set objCDO = Nothing
'Then Insert the new records
MM_editConnection = MM_GBsounds2OLE_STRING
MM_editTable = "users"
MM_editRedirectUrl = "regthanks.asp"
MM_fieldsStr = "First Name|value|Last Name|value|Username|value|Password|value|Contact Name|value|Email Address|value|Day Tel|value|Evening Tel|value|Mobile|value|AccessLevel|value"
MM_columnsStr = "FirstName|',none,''|LastName|',none,''|UserName|',none,''|UserPassword|',none,''|ContactName|',none,''|Email|',none,''|DayTel|',none,''|EveTel|',none,''|Mobile|',none,''|AccessLevel|none,none,NULL"
' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|"
MM_columns = Split(MM_columnsStr, "|"
' set the form values
For i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(i+1) = CStr(Request.Form(MM_fields(i)))
Next
' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And Request.QueryString <> "" Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "" Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If
End If
%>
<%
' *** Insert Record: construct a sql insert statement and execute it
If (CStr(Request("MM_insert") <> "" Then
Session("MM_Username" = cStr(Request("Username")
' create the sql insert statement
MM_tableValues = ""
MM_dbValues = ""
For i = LBound(MM_fields) To UBound(MM_fields) Step 2
FormVal = MM_fields(i+1)
MM_typeArray = Split(MM_columns(i+1),","
Delim = MM_typeArray(0)
If (Delim = "none" Then Delim = ""
AltVal = MM_typeArray(1)
If (AltVal = "none" Then AltVal = ""
EmptyVal = MM_typeArray(2)
If (EmptyVal = "none" Then EmptyVal = ""
If (FormVal = "" Then
FormVal = EmptyVal
Else
If (AltVal <> "" Then
FormVal = AltVal
ElseIf (Delim = "'" Then ' escape quotes
FormVal = "'" & Replace(FormVal,"'","''" & "'"
Else
FormVal = Delim + FormVal + Delim
End If
End If
If (i <> LBound(MM_fields)) Then
MM_tableValues = MM_tableValues & ","
MM_dbValues = MM_dbValues & ","
End if
MM_tableValues = MM_tableValues & MM_columns(i)
MM_dbValues = MM_dbValues & FormVal
Next
MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & " values (" & MM_dbValues & ""
If (Not MM_abortEdit) Then
' execute the insert
Set MM_editCmd = Server.CreateObject("ADODB.Command"
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
If (MM_editRedirectUrl <> "" Then
Response.Redirect(MM_editRedirectUrl)
End If
End If
End If
%></font id=code></pre id=code>
Basically set up the insert record behaviour, then put your CDONTS Email code after the <pre id=code><font face=courier size=2 id=code>If (CStr(Request("MM_insert") <> "" Then</font id=code></pre id=code>Line.
Regards
Owen.
Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
Edited by - oeastwick on 09/19/2001 01:04:39
Edited by - oeastwick on 09/19/2001 01:05:37
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Zain Magsi
Zain
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Zain, here is some code from the new user registration page for a site.
<pre id=code><font face=courier size=2 id=code>
<%
' *** Insert Record: set variables
If (CStr(Request("MM_insert") <> "" Then
'To Correct Server Time in U.S.A 6 hours behind UK time
ServerTime = Now()
CorrectTime = DateAdd("h",6,ServerTime)
MessageTo = Request("Email Address"
FirstName = Request("First Name"
LastName = Request("Last Name"
Username = Request("Username"
Password = Request("Password"
ContactName = Request("Contact Name"
EmailAddress = Request("Email Address"
DayTel = Request("Day Tel"
EveTel = Request("Evening Tel"
Mobile = Request("Mobile"
If DayTel = "" Then
DayTel = "No Number Provided"
End If
If EveTel = "" Then
EveTel = "No Number Provided"
End If
If Mobile = "" Then
Mobile = "No Number Provided"
End If
'The header/footer for the email
Header1 = "Hello "& FirstName &", many thanks for registering with GBsounds"
mail_Body = Header1 & vbCrLf & vbCrLf
mail_Body = mail_Body & "First Name: " & FirstName & vbCrLf
mail_Body = mail_Body & "Last Name: " & LastName & vbCrLf
mail_Body = mail_Body & "Username: " & Username & vbCrLf
mail_Body = mail_Body & "Password: " & Password & vbCrLf
mail_Body = mail_Body & "Contact Name: " & ContactName & vbCrLf
mail_Body = mail_Body & "Email Address: " & EmailAddress & vbCrLf
mail_Body = mail_Body & "Daytime Telephone: " & DayTel & vbCrLf
mail_Body = mail_Body & "Evening Telephone: " & EveTel & vbCrLf
mail_Body = mail_Body & "Mobile: " & Mobile & vbCrLf
'Create the mail object and send the mail
Dim objCDO
Set objCDO = Server.CreateObject("CDONTS.NewMail"
objCDO.To = MessageTo
objCDO.From = " "
objCDO.Subject = "GBsounds Registration Details"
objCDO.Body = mail_Body
objCDO.Send
Set objCDO = Nothing
'Then Insert the new records
MM_editConnection = MM_GBsounds2OLE_STRING
MM_editTable = "users"
MM_editRedirectUrl = "regthanks.asp"
MM_fieldsStr = "First Name|value|Last Name|value|Username|value|Password|value|Contact Name|value|Email Address|value|Day Tel|value|Evening Tel|value|Mobile|value|AccessLevel|value"
MM_columnsStr = "FirstName|',none,''|LastName|',none,''|UserName|',none,''|UserPassword|',none,''|ContactName|',none,''|Email|',none,''|DayTel|',none,''|EveTel|',none,''|Mobile|',none,''|AccessLevel|none,none,NULL"
' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|"
MM_columns = Split(MM_columnsStr, "|"
' set the form values
For i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(i+1) = CStr(Request.Form(MM_fields(i)))
Next
' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And Request.QueryString <> "" Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "" Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If
End If
%>
<%
' *** Insert Record: construct a sql insert statement and execute it
If (CStr(Request("MM_insert") <> "" Then
Session("MM_Username" = cStr(Request("Username")
' create the sql insert statement
MM_tableValues = ""
MM_dbValues = ""
For i = LBound(MM_fields) To UBound(MM_fields) Step 2
FormVal = MM_fields(i+1)
MM_typeArray = Split(MM_columns(i+1),","
Delim = MM_typeArray(0)
If (Delim = "none" Then Delim = ""
AltVal = MM_typeArray(1)
If (AltVal = "none" Then AltVal = ""
EmptyVal = MM_typeArray(2)
If (EmptyVal = "none" Then EmptyVal = ""
If (FormVal = "" Then
FormVal = EmptyVal
Else
If (AltVal <> "" Then
FormVal = AltVal
ElseIf (Delim = "'" Then ' escape quotes
FormVal = "'" & Replace(FormVal,"'","''" & "'"
Else
FormVal = Delim + FormVal + Delim
End If
End If
If (i <> LBound(MM_fields)) Then
MM_tableValues = MM_tableValues & ","
MM_dbValues = MM_dbValues & ","
End if
MM_tableValues = MM_tableValues & MM_columns(i)
MM_dbValues = MM_dbValues & FormVal
Next
MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & " values (" & MM_dbValues & ""
If (Not MM_abortEdit) Then
' execute the insert
Set MM_editCmd = Server.CreateObject("ADODB.Command"
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
If (MM_editRedirectUrl <> "" Then
Response.Redirect(MM_editRedirectUrl)
End If
End If
End If
%></font id=code></pre id=code>
Basically set up the insert record behaviour, then put your CDONTS Email code after the <pre id=code><font face=courier size=2 id=code>If (CStr(Request("MM_insert") <> "" Then</font id=code></pre id=code>Line.
Regards
Owen.
Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
Edited by - oeastwick on 09/19/2001 01:04:39
Edited by - oeastwick on 09/19/2001 01:05:37
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Zain Magsi