Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Login Scripts email function

Reply
 
Old 03-17-2009   #1 (permalink)
Desolator


 
 

Login Scripts email function

I have different contractors that log in from time to time and I keep track
of them with a login script the emails me me when they login. I have one for
every contractor but would like to have just one script. Here is where i
need help,

In the subject and message I identify the contractor specifically, however I
want to have a varaible that pulls the contractor's name from his login
username, something like %USERNAME%, but I don't know how to do it with
script. can any one help?

' Begin example
SMTPServer = "192.168.xxx.xxx"
Recipient = "yourcastle@xxxxxx"
From = "Login@xxxxxx"
Subject = "ESRI Has logged in"
Message = "ESRI has logged in to Draco."

' To add an attachment update the full path and uncomment the line
' There is one line below that must also be uncommented


'attachment = "c: \ test.txt"


' Call Sub and pass required data
GenericSendmail SMTPserver, From, Recipient, Subject, Message

' Begin Sub
' ------------------------------------------------------------------
' Generic function to send mail using a remote
' SMTP server. Pass SMTPserver, From address,
' Recipient address, Subject, and Message as arguments
' ------------------------------------------------------------------
Sub GenericSendmail (SMTPserver, From, Recipient, Subject, Message)

set msg = WScript.CreateObject("CDO.Message")
msg.From = From
msg.To = Recipient
msg.Subject = Subject
msg.TextBody = Message


msg.Configuration.Fields
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = SMTPServer
msg.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

msg.Configuration.Fields.Update

msg.Send

End Sub



Thanks

My System SpecsSystem Spec
Old 03-17-2009   #2 (permalink)
Pegasus [MVP]


 
 

Re: Login Scripts email function


"Desolator" <Desolator@xxxxxx> wrote in message
news:584C15F4-779A-4197-A196-6CDDCCE17545@xxxxxx
Quote:

>I have different contractors that log in from time to time and I keep track
> of them with a login script the emails me me when they login. I have one
> for
> every contractor but would like to have just one script. Here is where i
> need help,
>
> In the subject and message I identify the contractor specifically, however
> I
> want to have a varaible that pulls the contractor's name from his login
> username, something like %USERNAME%, but I don't know how to do it with
> script. can any one help?
>
> ' Begin example
> SMTPServer = "192.168.xxx.xxx"
> Recipient = "yourcastle@xxxxxx"
> From = "Login@xxxxxx"
> Subject = "ESRI Has logged in"
> Message = "ESRI has logged in to Draco."
>
> ' To add an attachment update the full path and uncomment the line
> ' There is one line below that must also be uncommented
>
>
> 'attachment = "c: \ test.txt"
>
>
> ' Call Sub and pass required data
> GenericSendmail SMTPserver, From, Recipient, Subject, Message
>
> ' Begin Sub
> ' ------------------------------------------------------------------
> ' Generic function to send mail using a remote
> ' SMTP server. Pass SMTPserver, From address,
> ' Recipient address, Subject, and Message as arguments
> ' ------------------------------------------------------------------
> Sub GenericSendmail (SMTPserver, From, Recipient, Subject, Message)
>
> set msg = WScript.CreateObject("CDO.Message")
> msg.From = From
> msg.To = Recipient
> msg.Subject = Subject
> msg.TextBody = Message
>
>
> msg.Configuration.Fields
> ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = SMTPServer
> msg.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing")
> = 2
>
> msg.Configuration.Fields.Update
>
> msg.Send
>
> End Sub
Download script56.chm from the Microsoft site, then search it for the string
"environmental" (because %Username% is an env. variable!).


My System SpecsSystem Spec
Old 03-17-2009   #3 (permalink)
Al Dunbar


 
 

Re: Login Scripts email function


"Pegasus [MVP]" <news@xxxxxx> wrote in message
news:e9Rbu20pJHA.4564@xxxxxx
Quote:

>
> "Desolator" <Desolator@xxxxxx> wrote in message
> news:584C15F4-779A-4197-A196-6CDDCCE17545@xxxxxx
Quote:

>>I have different contractors that log in from time to time and I keep
>>track
>> of them with a login script the emails me me when they login. I have one
>> for
>> every contractor but would like to have just one script. Here is where i
>> need help,
>>
>> In the subject and message I identify the contractor specifically,
>> however I
>> want to have a varaible that pulls the contractor's name from his login
>> username, something like %USERNAME%, but I don't know how to do it with
>> script. can any one help?
>>
>> ' Begin example
>> SMTPServer = "192.168.xxx.xxx"
>> Recipient = "yourcastle@xxxxxx"
>> From = "Login@xxxxxx"
>> Subject = "ESRI Has logged in"
>> Message = "ESRI has logged in to Draco."
>>
>> ' To add an attachment update the full path and uncomment the line
>> ' There is one line below that must also be uncommented
>>
>>
>> 'attachment = "c: \ test.txt"
>>
>>
>> ' Call Sub and pass required data
>> GenericSendmail SMTPserver, From, Recipient, Subject, Message
>>
>> ' Begin Sub
>> ' ------------------------------------------------------------------
>> ' Generic function to send mail using a remote
>> ' SMTP server. Pass SMTPserver, From address,
>> ' Recipient address, Subject, and Message as arguments
>> ' ------------------------------------------------------------------
>> Sub GenericSendmail (SMTPserver, From, Recipient, Subject, Message)
>>
>> set msg = WScript.CreateObject("CDO.Message")
>> msg.From = From
>> msg.To = Recipient
>> msg.Subject = Subject
>> msg.TextBody = Message
>>
>>
>> msg.Configuration.Fields
>> ("http://schemas.microsoft.com/cdo/configuration/smtpserver") =
>> SMTPServer
>> msg.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing")
>> = 2
>>
>> msg.Configuration.Fields.Update
>>
>> msg.Send
>>
>> End Sub
>
> Download script56.chm from the Microsoft site, then search it for the
> string "environmental" (because %Username% is an env. variable!).
Or do it directly in vbscript using the network object:

http://msdn.microsoft.com/en-us/libr...3f(VS.85).aspx

/Al


My System SpecsSystem Spec
Old 04-23-2009   #4 (permalink)
David


 
 

Re: Login Scripts email function

Try this in a vbs file during logon, works for us:

Set WshNetwork = WScript.CreateObject("WScript.Network")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objEmail = CreateObject("CDO.Message")
objEmail.From = " & WshNetwork.username & "@domain.com"
objEmail.To = "username@xxxxxx"
objEmail.Subject = "User " & WshNetwork.UserName &" Logged on"
objEmail.Textbody = ""
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _
"servername"
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Update
objEmail.Send



"Desolator" <Desolator@xxxxxx> wrote in message
news:584C15F4-779A-4197-A196-6CDDCCE17545@xxxxxx
Quote:

>I have different contractors that log in from time to time and I keep track
> of them with a login script the emails me me when they login. I have one
> for
> every contractor but would like to have just one script. Here is where i
> need help,
>
> In the subject and message I identify the contractor specifically, however
> I
> want to have a varaible that pulls the contractor's name from his login
> username, something like %USERNAME%, but I don't know how to do it with
> script. can any one help?
>
> ' Begin example
> SMTPServer = "192.168.xxx.xxx"
> Recipient = "yourcastle@xxxxxx"
> From = "Login@xxxxxx"
> Subject = "ESRI Has logged in"
> Message = "ESRI has logged in to Draco."
>
> ' To add an attachment update the full path and uncomment the line
> ' There is one line below that must also be uncommented
>
>
> 'attachment = "c: \ test.txt"
>
>
> ' Call Sub and pass required data
> GenericSendmail SMTPserver, From, Recipient, Subject, Message
>
> ' Begin Sub
> ' ------------------------------------------------------------------
> ' Generic function to send mail using a remote
> ' SMTP server. Pass SMTPserver, From address,
> ' Recipient address, Subject, and Message as arguments
> ' ------------------------------------------------------------------
> Sub GenericSendmail (SMTPserver, From, Recipient, Subject, Message)
>
> set msg = WScript.CreateObject("CDO.Message")
> msg.From = From
> msg.To = Recipient
> msg.Subject = Subject
> msg.TextBody = Message
>
>
> msg.Configuration.Fields
> ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = SMTPServer
> msg.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing")
> = 2
>
> msg.Configuration.Fields.Update
>
> msg.Send
>
> End Sub
>
>
>
> Thanks
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
most effective way via javascript login scripts to allow login rightsto all our servers to our Network Team group VB Script
Login scripts vs UAC Vista General
Login Scripts Vista networking & sharing
Login Scripts Not Running Vista networking & sharing
More Login Scripts Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46