Forums
This topic is locked
Insert Record/Send Email
Posted 23 Feb 2006 23:11:20
1
has voted
23 Feb 2006 23:11:20 Peter Lent posted:
Hi All,I am trying to either find the code or an extension that will allow me to insert a new record, and then notify the site admin of the new record.
I am using:
DWMX | ASP | ACCESS
Also have Smart Mailer extension, and Ultra Suite.
TIA
Peter
Replies
Replied 25 Feb 2006 02:42:36
25 Feb 2006 02:42:36 Jeremy Conn replied:
I am not sure about an extension or not, but here is the way I successfully accomplish that.
This code allows you to have a CDONTS email sent when a record is added using the DW Insert Behavior.
<b>WHERE TO ADD CODE BLOCK</b>
Add the code between these two sections of the standard DW Insert Behavior.
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
--> CODE WILL GO HERE
If (MM_editRedirectUrl <> ""
Then
Response.Redirect(MM_editRedirectUrl)
End If
End If
<b>EMAIL CODE BLOCK</b>
Add this code between these two sections of the standard DW Insert Behavior.
Items that would need to be changed to fit your unique situation are highlighted in <font color=green>GREEN</font id=green>.
' Send email item has been added
strMessage = "<font color=green>Notification of New Addition</font id=green>" & VbCrlf & VbCrlf
strMessage = strMessage & "<font color=green>Item Added: " & Request.Form("ItemTitle"
</font id=green> & VbCrlf
Set objMail = Server.CreateObject("CDONTS.NewMail"
objMail.To = "<font color=green> </font id=green>"
objMail.From = "<font color=green> </font id=green>"
objMail.Subject = "<font color=green>Notification of New Addition</font id=green>"
objMail.Body = strMessage
objMail.Send
Set objMail = Nothing
' Finished sending email
<b>Jeremy Conn</b>
www.conncreativemedia.com
DWMX2004 | ASP/VB | Access/SQL2000
This code allows you to have a CDONTS email sent when a record is added using the DW Insert Behavior.
<b>WHERE TO ADD CODE BLOCK</b>
Add the code between these two sections of the standard DW Insert Behavior.
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
--> CODE WILL GO HERE
If (MM_editRedirectUrl <> ""

Response.Redirect(MM_editRedirectUrl)
End If
End If
<b>EMAIL CODE BLOCK</b>
Add this code between these two sections of the standard DW Insert Behavior.
Items that would need to be changed to fit your unique situation are highlighted in <font color=green>GREEN</font id=green>.
' Send email item has been added
strMessage = "<font color=green>Notification of New Addition</font id=green>" & VbCrlf & VbCrlf
strMessage = strMessage & "<font color=green>Item Added: " & Request.Form("ItemTitle"

Set objMail = Server.CreateObject("CDONTS.NewMail"

objMail.To = "<font color=green> </font id=green>"
objMail.From = "<font color=green> </font id=green>"
objMail.Subject = "<font color=green>Notification of New Addition</font id=green>"
objMail.Body = strMessage
objMail.Send
Set objMail = Nothing
' Finished sending email
<b>Jeremy Conn</b>
www.conncreativemedia.com
DWMX2004 | ASP/VB | Access/SQL2000
Replied 05 Mar 2006 02:07:12
05 Mar 2006 02:07:12 Jeremy Conn replied:
Replied 05 Mar 2006 03:05:39
05 Mar 2006 03:05:39 Peter Lent replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Did this help?
<b>Jeremy Conn</b>
www.conncreativemedia.com
DWMX2004 | ASP/VB | Access/SQL2000
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
YES, It worked great, sorry for not replying.
THANKS!!!!
Pete
Did this help?
<b>Jeremy Conn</b>
www.conncreativemedia.com
DWMX2004 | ASP/VB | Access/SQL2000
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
YES, It worked great, sorry for not replying.
THANKS!!!!
Pete