seaninman
asked on
Help with a VBScript
I have this script and I was wondering how I could make it so that when executed it would only send an email when the account was disabled and not when the account is already disabled. See my plans are to have this ran everyday through a scheduler and i dont want to get an email every day if the account is already disabled. I only want to know when it was disabled if it was previously enabled.
strUserDN = "CN=test,OU=Test Accounts,OU=Security,DC=inc,DC=com"
Set objUser = GetObject("LDAP://" & strUserDN)
objUser.AccountDisabled = True
objUser.SetInfo
' Email variables:
strServer = "smtp.inc.com"
strTo = "test@test.com"
strFrom = "AcctControlAdmin@test.com"
strSubject = "Account was disabled."
strBody = "The Account was disabled." & VbCrLf
SendEmail strServer, strTo, strFrom, strSubject, strBody, ""
Sub SendEmail(strServer, strTo, strFrom, strSubject, strBody, strAttachment)
Dim objMessage
Set objMessage = CreateObject("CDO.Message")
objMessage.To = strTo
objMessage.From = strFrom
objMessage.Subject = strSubject
objMessage.TextBody = strBody
If strAttachment <> "" Then objMessage.AddAttachment strAttachment
'==This section provides the configuration information for the remote SMTP server.
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strServer
'Server port (typically 25)
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMessage.Configuration.Fields.Update
'==End remote SMTP server configuration section==
objMessage.Send
Set objMessage = Nothing
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER