Hey guys,
I have a script that will send me an email. However I would like it to only send me an email if the ip changed from the previous day.
For instance I have it scheduled to run daily at 7am. It then compares the current IP to the previous IP (in a text file) and if it is different then email the new IP.
This is what i have
- Matt
"If I must boast, I will boast of the things that show my weakness"
- Windows 2003 Server, 98 SE, XP
- VB.NET, VSTS 2010, ASP.NET, EXCEL VBA, ACCESS, SQL 2008
I have a script that will send me an email. However I would like it to only send me an email if the ip changed from the previous day.
For instance I have it scheduled to run daily at 7am. It then compares the current IP to the previous IP (in a text file) and if it is different then email the new IP.
This is what i have
Code:
Set wshShell = WScript.CreateObject( "WScript.Shell" )
strComputerName = wshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" )
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputerName & "\root\cimv2")
Set colItems = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
For Each objitem In colitems
strIPAddress = Join(objitem.IPAddress, ",")
'WScript.Echo strIPAddress
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "IPAddress@****.com"
objEmail.To = "Matt.Loflin@****.com"
objEmail.Subject = "IP Address - " & strComputerName
objEmail.Textbody = strIPAddress
objEmail.Configuration.Fields.Item _
("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusing")[/URL] = 2
objEmail.Configuration.Fields.Item _
("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserver")[/URL] = _
"webmail.****.com"
objEmail.Configuration.Fields.Item _
("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserverport")[/URL] = 25
objEmail.Configuration.Fields.Update
objEmail.Send
Exit For
Next
- Matt
"If I must boast, I will boast of the things that show my weakness"
- Windows 2003 Server, 98 SE, XP
- VB.NET, VSTS 2010, ASP.NET, EXCEL VBA, ACCESS, SQL 2008