' This script sends an e-mail after a profile has run ' This script was written by TGRMN Software along with contributions from a few of our users ' ' Edit the fields that have ***** and leave the quotes in place ' USERNAME = "*****username" ' replace with your e-mail user PASSWORD = "*****pwd" ' replace with your e-mail password FROM_EMAIL = "*****email-from" ' replace with the e-mail you want to send messages from TO_EMAIL = "*****email-to" ' replace with the e-mail you want to send messages to SMTP_EMAIL_SERVER = "*****smtp" ' replace with your e-mail SMTP server SEND_EMAIL_ONLY_IFERROR = True ' Send e-mail only if run results in error (False or True) ' Usually the following variables do not need to be changed ' PORT = 25 ' Typically SMTP port is 25, so probably no need to change this SSL = False 'Use SSL for the connection (False or True) '*********************************************** '******** No need to edit below these lines **** '*********************************************** WScript.Echo "User Name: " & USERNAME WScript.Echo "Password: *" WScript.Echo "From E-Mail: " & FROM_EMAIL WScript.Echo "To E-Mail: " & TO_EMAIL WScript.Echo "SMTP Server: " & SMTP_EMAIL_SERVER WScript.Echo "Send only if error: " & SEND_EMAIL_ONLY_IFERROR WScript.Echo "Port: " & PORT WScript.Echo "Ssl: " & SSL Dim result Dim explanation Dim exitcode Dim Profilename Dim profilepath Dim sourcefolder Dim targetfolder Dim executionmethod Dim exitcodes(17) Set objMessage = CreateObject("CDO.Message") Set WshShell = WScript.CreateObject("WScript.Shell") profilename = WshShell.Environment("PROCESS").Item("VV_PROFILE_NAME") profilepath = WshShell.Environment("PROCESS").Item("VV_PROFILE_PATH") exitcode = WshShell.Environment("PROCESS").Item("VV_EXIT_CODE") sourcefolder = WshShell.Environment("PROCESS").Item("VV_SOURCE_FOLDER") targetfolder = WshShell.Environment("PROCESS").Item("VV_TARGET_FOLDER") comparisontype = WshShell.Environment("PROCESS").Item("VV_COMPARISON_TYPE") executionmethod = WshShell.Environment("PROCESS").Item("VV_EXECUTION_METHOD") executionmethoddesc = WshShell.Environment("PROCESS").Item("VV_EXECUTION_METHOD_DESC") execsummary = WshShell.Environment("PROCESS").Item("VV_RUN_SUMMARY") statussummary = WshShell.Environment("PROCESS").Item("VV_FINAL_STATUS_SUMMARY") conflicts = WshShell.Environment("PROCESS").Item("VV_CONFLICT_SUMMARY") exitcodedesc = WshShell.Environment("PROCESS").Item("VV_EXIT_CODE_DESC") userenv = WshShell.Environment("PROCESS").Item("USERNAME") computernameenv = WshShell.Environment("PROCESS").Item("COMPUTERNAME") Const cdoSendUsingPickup = 1 'Send message using the local SMTP service pickup directory. Const cdoSendUsingPort = 2 'Send the message using the network (SMTP over the network). Const cdoAnonymous = 0 'Do not authenticate Const cdoBasic = 1 'basic (clear-text) authentication Const cdoNTLM = 2 'NTLM objMessage.From = FROM_EMAIL objMessage.To = TO_EMAIL objMessage.Subject = "Profile: " & profilename & " - Exit Code: " & exitcode objMessage.TextBody = exitcodedesc & vbCrLf & "Profile: " & profilename & vbCrLf & "Exit Code: " & exitcode & vbCrLf & "Source: " & sourcefolder & vbCrLf & "Target: " & targetfolder & vbCrLf & "User: " & userenv & vbCrLf & "Computer Name: " & computernameenv & vbCrLf & vbCrLf & executionmethoddesc & vbCrLf & vbCrLf & execsummary & vbCrLf & vbCrLf & statussummary & vbCrLf & vbCrLf & conflicts objMessage.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort 'Type of authentication, NONE, Basic (Base64 encoded), NTLM objMessage.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic objMessage.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = SMTP_EMAIL_SERVER 'Your UserID on the SMTP server objMessage.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/sendusername") = USERNAME 'Your password on the SMTP server objMessage.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = PASSWORD 'Server port (typically 25) objMessage.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = PORT 'Use SSL for the connection (False or True) objMessage.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = SSL 'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server) objMessage.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60 If SEND_EMAIL_ONLY_IFERROR = False Or exitcode > 0 Then WScript.Echo "Sending e-mail message to '" & TO_EMAIL & "' from '" & FROM_EMAIL & "'" objMessage.Configuration.Fields.Update objMessage.Send WScript.Echo "DONE." Else WScript.Echo "Exit code is equal to zero, e-mail will not be sent" End If