This topic is locked

Email send after ercord update

3/17/2006 12:30:43 PM
ASPRunnerPro General questions
R
robs author

I am currently testing ASRUNNER 4.0

Each user has its own user name and password for login.

I want to be able to send email after record was modified or added.

I want to know the TIME, USER who did it and changes that were made.

How would I modify the code below?
Sub AfterEdit()
email="test@test.com"

message="Hello there" & vbcrlf & "Best regards"

subject="Sample subject"

sendmail email, subject, message

End Sub

Sergey Kornilov admin 3/19/2006

Try something like this:
Sub AfterEdit()

email="test@test.com"

message="Hello there" & vbcrlf & "Best regards" & vbcrlf & Now() & vbcrlf & Session("UserID")

subject="Sample subject"

sendmail email, subject, message

End Sub
N
npala2001 3/20/2006

Is there a way to also send in an email what record was changed or added?

R
robs author 3/20/2006

Sergey,

This worked great. THANKS!
Now taking this to a different level...

I have table (backup_table) with all the same fields as the primary table.

Here is what I want to accomplish:

  • Every time record is EDIT (this could be more than one time) I want to be able to copy old data record to backup_table showing USER and TIME who did it.
    This would track all changes being made in our MS Access db.

    Thanks in advance!

Sergey Kornilov admin 3/20/2006

Robs,
use BeforeEditEvent and sample action Save old data record in another table. Use Now() to get current datetime and Session("UserID") to get logged user name.
Something like this:

Function BeforeEdit(dict, where)
' Parameters:

' dict - Scripting.Dictionary object.

' Each field on the Edit form represented as 'Field name'-'Field value' pair

' where - string with WHERE clause pointing to record to be edited
'********** Save old data record in another table ************

strSQLSave = "INSERT INTO AnotherTable (Field1, Field2, TimeModified, ModifiedBy) SELECT Field1, Field2, Now(), '" & Session("UserID") & "' FROM " & strTableName & " where " & where

dbConnection.Execute strSQLSave
BeforeEdit = True
' set BeforeEdit to True if you like to proceed with editing this record

' set it to False in other case
End Function
R
robs author 3/20/2006

Sergey,
You are THE MAN!
Last question,
How would I send email on EDIT for changes on ONLY specific fields in the record?
Thanks in advance again!

Sergey Kornilov admin 3/21/2006

Robs,
you need to retrieve existing data record and compare it with new values.
After you purchase contact me directly at support@xlinesoft.com and I'll send you code snippet as applies to your database structure.

N
NigelEtienne 3/21/2006

Robs,

you need to retrieve existing data record and compare it with new values.
After you purchase contact me directly at support@xlinesoft.com and I'll send you code snippet as applies to your database structure.



Sergey,

I am working on the same problem can you send me the "code snippet" as well?

R
robs author 3/21/2006



Sergey,

I am working on the same problem can you send me the "code snippet" as well?


We will thank you!

Sergey Kornilov admin 3/21/2006

Nigel,
sure, contact me at support@xlinesoft.com. I might need some additional info from you.

N
npala2001 3/21/2006

I never got a response to my question.
Is there a way to submit an email to an admin once a record has been added/edited in the database by a user informing the admin what change occured.

Sergey Kornilov admin 3/22/2006

Hi,
you can do it using events.

Select Send email with new data for Before record added event and Send email with old data or/and Send email with new data for Before record edited event on the Events Tab.
Current user number is stored in Session("UserID").

bajrai 6/18/2006

Hi Sergey,
I try below code send email with userid, My result was with all the text, datetime but userid did not appear . Can assist me please.
Thanks

<img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=9161&image=1&table=forumreplies' class='bbcemoticon' alt='<<' />

Try something like this:

Sub AfterEdit()

email="test@test.com"

message="Hello there" & vbcrlf & "Best regards" & vbcrlf & Now() & vbcrlf & Session("UserID")

subject="Sample subject"

sendmail email, subject, message

End Sub

J
Jane 6/19/2006

Hi,
To make this event code working create LOGIN page on the Security tab (step 9) in the ASPRunnerPro.

bajrai 6/19/2006

Hi Jane,
Thank you for your respond.
Yes I do have a login page. It did send an email out after login but the userid info is missing.!!

All the other field appear but "Session("UserID")" there was no error sending the email.

I received email message without userid.
I must did something not correct here.

Thanks

Hi,

To make this event code working create LOGIN page on the Security tab (step 9) in the ASPRunnerPro.

J
Jane 6/20/2006

Please zip and send to [email=support@xlinesoft.com]support@xlinesoft.com[/email] a full set of generated ASP files along with database file.

I'll find what's wrong with your project running it on my test box.

Sergey Kornilov admin 6/20/2006

Try to print Session("UserID") somewhere on the page to make sure it's populated.

Response.Write Session("UserID")