[xml]$uber = iwr http://feeds.feedburner.com/ubergizmo $articles = $uber.GetElementsByTagName('item') foreach ($a in $articles){ $title = $a.title $title = $title.replace("???","'") $title = $title.replace("??",'"') $link = $a.link $html = New-Object -ComObject "HTMLFile" $article = $a.encoded.'#cdata-section' $html.IHTMLDocument2_write($article) $imglink = $html.body.getelementsbytagname('img')[0].src $text = $html.body.innertext $text = $text.replace("???","'") $text = $text.replace("??",'"') $a.creator = ("<table width='100%'><tr><td style=font-family: Arial, sans-serif;><a href=$link><img width=200 align=left src=" + $imglink + "></a><center><h3>" + $title + "</h3></center></td></tr></table><table width='100%'><tr><td style='font-family: Arial, sans-serif;font-size:13;'><p>" + $text + "</p></td></tr></table><hr style='border: 2px solid mintcream;'>") [System.Runtime.Interopservices.Marshal]::ReleaseComObject($html)|out-null } $SMTPServer = "smtp.gmail.com" $SMTPPort = "587" $Username = "myemail@gmail.com" $Password = "mypassword" $to = "recipient@somemail.com" $subject = ("Ubergizmo - " + (get-date).tolongdatestring()) $body = $articles.creator $message = New-Object System.Net.Mail.MailMessage $message.subject = $subject $message.body = $body $message.to.add($to) $message.from = $username $message.IsBodyHTML = $true $smtp = New-Object System.Net.Mail.SmtpClient($SMTPServer, $SMTPPort); $smtp.EnableSSL = $true $smtp.Credentials = New-Object System.Net.NetworkCredential($Username, $Password); $smtp.send($message)
PS C:\Scripts>Write-host "The Best Way To Predict The Future" -foreground white The Best Way To Predict The Future PS C:\Scripts>"is to create it!"|for-each {write-host $_.toupper() -foreground white} IS TO CREATE IT!
Friday, September 22, 2017
PowerShell: Invoke-WebRequest Create Emailer from Ubergizmo RSS Feed
Use this code to create an emailer using Ubergizmo's RSS feed:
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment