This topic is locked

Username added to login event email

9/16/2009 11:49:41
ASPRunnerPro General questions
author

How would I add the user name or user id to the email I get when someone logs in? Thanks!
Here is the event code:



dim tmpDict

set tmpDict = CreateObject("Scripting.Dictionary")

tmpDict("to")="me@gmail.com"

tmpDict("subject")="Login"

tmpDict("body")="Someone has logged in. FYI."

set ret=runner_mail(tmpDict)

if not ret("mailed") then

response.write ret("message")

end if
C
clig 9/16/2009



How would I add the user name or user id to the email I get when someone logs in? Thanks!
Here is the event code:



dim tmpDict

set tmpDict = CreateObject("Scripting.Dictionary")

tmpDict("to")="me@gmail.com"

tmpDict("subject")="Login"

tmpDict("body")="Someone has logged in. FYI."

set ret=runner_mail(tmpDict)

if not ret("mailed") then

response.write ret("message")

end if



if you have an email field in your user table assign a session var or use rsexists or existing sessions:
tmpDict("body")="Someone has logged in - username: " & Session("UserID")
// After successful login

Sub AfterSuccessfulLogin(username,password)
strSQLExists = "Select Name, Email, Role, simsLogin, simsRepNo, Identifier, DistList From NTSS_USERS Where LoginName = " & "'" & cstr(SESSION("UserID")) & "'"

set rsExists = CreateObject("ADODB.Recordset")

rsExists.Open strSQLExists, dbConnection
if not rsExists.eof then

SESSION("UserIDName") = rsExists("Name")

SESSION("UserIDEmail") = rsExists("Email")

SESSION("UserIDRole") = rsExists("Role")

SESSION("simsLogin") = rsExists("simsLogin")

SESSION("simsRepNo") = rsExists("simsRepNo")

SESSION("Identifier") = rsExists("Identifier")

SESSION("DistList") = rsExists("DistList")

Session("LogiDatTim") = Now()

else
end if

rsExists.Close : set rsExists = Nothing
End Sub ' AfterSuccessfulLogin

501360 9/16/2009



if you have an email field in your user table assign a session var or use rsexists or existing sessions:
tmpDict("body")="Someone has logged in - username: " & Session("UserID")
// After successful login

Sub AfterSuccessfulLogin(username,password)
strSQLExists = "Select Name, Email, Role, simsLogin, simsRepNo, Identifier, DistList From NTSS_USERS Where LoginName = " & "'" & cstr(SESSION("UserID")) & "'"

set rsExists = CreateObject("ADODB.Recordset")

rsExists.Open strSQLExists, dbConnection
if not rsExists.eof then

SESSION("UserIDName") = rsExists("Name")

SESSION("UserIDEmail") = rsExists("Email")

SESSION("UserIDRole") = rsExists("Role")

SESSION("simsLogin") = rsExists("simsLogin")

SESSION("simsRepNo") = rsExists("simsRepNo")

SESSION("Identifier") = rsExists("Identifier")

SESSION("DistList") = rsExists("DistList")

Session("LogiDatTim") = Now()

else
end if

rsExists.Close : set rsExists = Nothing
End Sub ' AfterSuccessfulLogin


Thanks, but that looks far too complicated for me to use! Can't I just add the Username / userID to the event? Sorry to be such a tool.

C
clig 9/16/2009



Thanks, but that looks far too complicated for me to use! Can't I just add the Username / userID to the event? Sorry to be such a tool.


dim tmpDict

set tmpDict = CreateObject("Scripting.Dictionary")

tmpDict("to")="me@gmail.com"

tmpDict("subject")="Login"

tmpDict("body")="Someone has logged in. FYI. - Username: " & Session("UserID")

set ret=runner_mail(tmpDict)

if not ret("mailed") then

response.write ret("message")

end if

501361 9/16/2009

Clig: Beautiful! That worked perfectly. Thanks a ton.

C
clig 9/16/2009



Clig: Beautiful! That worked perfectly. Thanks a ton.


anytime