Feb 23, 2012

SCCM reports by email

$URL = “http://SERVERURL/SMSReporting_000/Report.asp?ReportID=68&variable=4.00.6487.2157&type=1″
$SMTPServer = “mail.domain.com”
$sendername = “SCCM”
$senderAddress = “Sccm@domain.com”
$Recipient = “user@domain.com”
$strSubject = “Test”
$ie = new-object -comobject InternetExplorer.Application
$ie.navigate($URL)
While ($ie.Busy)
{ Start-Sleep -Milliseconds 400 }
$doc = $ie.document
$strbody = $doc.body.outerhtml
$ie.quit()
$Sender = “`”$SenderName`” `”
$msg = new-Object -comobject “CDO.Message”;
$msg.Configuration.Fields.Item(“http://schemas.microsoft.com/cdo/configuration/sendusing”) = 2
$msg.Configuration.Fields.Item(“http://schemas.microsoft.com/cdo/configuration/smtpserver”) = $SMTPServer
$msg.Configuration.Fields.item(“http://schemas.microsoft.com/cdo/configuration/smtpauthenticate”) = 2
$msg.Configuration.Fields.Item(“http://schemas.microsoft.com/cdo/configuration/smtpserverport”) = 25
$msg.Configuration.Fields.Update()
$msg.From = $Sender
$msg.To = $Recipient
$msg.Subject = $strSubject
$msg.HTMLBody = $strbody
$msg.Send()

No comments:

Post a Comment