This topic is locked

E-Mail information of an Add Page

8/23/2004 2:46:38 AM
ASPRunnerPro General questions
V
visual author

Hi to all
I would like to signal by e-mail new transactions to an e-mail adress containing all fields with the e-mail address entered in the transaction (sender).
As a non-techie I am looking for assistance
Many thanks
fingur6

Sergey Kornilov admin 8/27/2004

Hi,
you can use the following code snippet to send yourself an email with new data record added. Just make sure you put correct email addresses there.

strToEmail = "bgates@microsoft.com"

strEmailAddress = "bgates@microsoft.com"
Dim objCDO
Set objCDO = Server.CreateObject("CDO.Message")

objCDO.To = strToEmail

objCDO.From = strEmailAddress

objCDO.Subject = "New record was added"

objCDO.TextBody = "New record was added" & vbcrlf
For i = 1 To Request.Form("FieldName").Count
  objCDO.TextBody = objCDO.TextBody & Request.Form("FieldName")(i) & ": " & Request.Form(Request.Form("FieldName")(i)) & vbcrlf
Next
objCDO.Send

Set objCDO = Nothing


I hope this helps.

V
visual author 9/7/2004

Thanks Sergey
I added the code just below 'New record was added' and get now an e-mail alert whenever a record is added.
Very helpful!

unique1 10/8/2004

Can you tell me which page you add this code to and exatly where?

V
visual author 10/9/2004

I improved the code by testing if record has been actually entered. Code has been inserted in _add.asp just below
if strADOXTableName<>"" then set oCat=Nothing

If message <> "" then
strToEmail = Trim(Session ("EMail"))

strEmailAddress = Trim(Request.Form(Request.Form("FieldName")(16)))



   
Dim objCDO
Set objCDO = Server.CreateObject("CDO.Message")

objCDO.To = strToEmail

objCDO.From = strEmailAddress

objCDO.Subject = Session ("Referenz")& ": Kurzbewerbung von www.pks-personal.ch";

objCDO.TextBody = "Eine neue Bewerbung wurde der Datenbank zugefügt" & vbcrlf
For i = 1 To Request.Form("FieldName").Count
 objCDO.TextBody = objCDO.TextBody & Request.Form("FieldName")(i) & ": " & Request.Form(Request.Form("FieldName")(i)) & vbcrlf
Request.Form(Request.Form("FieldName")(i)) & vbcrlf
Next
objCDO.Send

Set objCDO = Nothing
end if


Hope this is of use for you
Erich

unique1 10/9/2004

Thank you, I added it but it's not working right <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=2612&image=1&table=forumreplies' class='bbc_emoticon' alt=':(' />