I would like to get a customized eMail notifications for the SCCM web reports which I am interested. Below is the simple script we can use to get eMail alerts in regular intervals.
Note ==> Need to create a scheduled task to run this script if you need the output of the SCCM report regularly or in a specific interval.
<Make necessary changes as per environment and try this in LAB environment before implementing this on Production>
Set WshShell = WScript.CreateObject(“WScript.Shell”)
Set objStream = Createobject(“ADODB.Stream”)
Set xmlhttp = CreateObject(“Microsoft.XmlHttp”)
url=”ENTER THE URL OF THE REPORT”
htmlReport=”EXACT PATH WHERE YOU NEED TO STORE THE HTML REPORT”
xmlhttp.open “Post”, url, False
xmlhttp.setRequestHeader “Content-Type”, “application/x-www-form-urlencoded”
xmlhttp.send “print=yes”
objStream.type = 1
objStream.open
objStream.Write xmlhttp.responseBody
objStream.savetofile htmlReport, 2
objStream.Close
Set objMessage = CreateObject(“CDO.Message”)
objMessage.Subject = “Sites by hierarchy with time of last site status update”
objMessage.From = “[email protected]”
objMessage.To = “PUT THE EMAIL ADDRESS OF THE RECEIPT”
‘objMessage.Cc = “<>”
objMessage.CreateMHTMLBody “EXACT PATH WHERE YOU NEED TO STORE THE HTML REPORT”
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”) = “SMTP SERVER NAME”
‘Server port (typically 25)
objMessage.Configuration.Fields.Item(“http://schemas.microsoft.com/cdo/configuration/smtpserverport”) = 25
objMessage.Configuration.Fields.Update
objMessage.Send
Set objMessage=Nothing
Set WshShell = Nothing
Set xmlHttp= Nothing
WScript.Echo “Script Execution Finished”