[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:
PowerShell: Invoke-WebRequest Phone Arena RSS Feed Emailer
Use this code if you'd like an emailer from Phone Arena:
[xml]$phonearena = iwr "https://www.phonearena.com/feed" $news = $phonearena.rss.channel.item foreach ($n in $news){ $link = $n.link $title = $n.title $html = New-Object -ComObject "HTMLFile" $getimglink = ($n.description.'#cdata-section') $html.IHTMLDocument2_write($getimglink) $imglink = $html.body.getelementsbytagname('img')|select -expand src $text = $html.body.innertext $n.author = ("<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><tr><td style='font-family: Arial, sans-serif;font-size:13;'>" + $text + "</td></tr></table><hr style='border: 2px solid mintcream;'>") [System.Runtime.Interopservices.Marshal]::ReleaseComObject($html)|out-null } $body = $news.author $body = $body.replace("???",'"') $SMTPServer = "smtp.gmail.com" $SMTPPort = "587" $Username = "mymail@gmail.com" $Password = "mypassword" $to = "recipient@somemail.com" $subject = ("Phone Arena - " + (get-date).tolongdatestring()) $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)
PowerShell: Invoke-WebRequest SlashDot RSS Feed Emailer
Use the following code if you want an emailer using Slashdot's RSS service:
[xml]$slashdot = iwr http://rss.slashdot.org/Slashdot/slashdotMain $articles = $slashdot.getelementsbytagname('item') foreach ($a in $articles){ $link = $a.link $title = $a.title $comments = $a.comments $department = $a.department $description = $a.description if ($a.subject -eq "iphone"){$subjecticon = "<img align=left vspace=2 hspace=5 align=left vspace=2 hspace=5 src=https://a.fsdn.com/sd/topics/iphone_64.png>"} if ($a.subject -eq "money"){$subjecticon = "<img align=left vspace=2 hspace=5 src=https://a.fsdn.com/sd/topics/money_64.png>"} if ($a.subject -eq "microsoft"){$subjecticon = "<img align=left vspace=2 hspace=5 src=https://a.fsdn.com/sd/topics/microsoft_64100.png>"} if ($a.subject -eq "privacy"){$subjecticon = "<img align=left vspace=2 hspace=5 src=https://a.fsdn.com/sd/topics/privacy_64.png>"} if ($a.subject -eq "eu"){$subjecticon = "<img align=left vspace=2 hspace=5 src=https://a.fsdn.com/sd/topics/eu_64.png>"} if ($a.subject -eq "encryption"){$subjecticon = "<img align=left vspace=2 hspace=5 src=https://a.fsdn.com/sd/topics/encryption_64.png>"} if ($a.subject -eq "firefox"){$subjecticon = "<img align=left vspace=2 hspace=5 src=https://a.fsdn.com/sd/topics/firefox_64.png>"} if ($a.subject -eq "security"){$subjecticon = "<img align=left vspace=2 hspace=5 src=https://a.fsdn.com/sd/topics/security_64.png>"} if ($a.subject -eq "social"){$subjecticon = "<img align=left vspace=2 hspace=5 src=https://a.fsdn.com/sd/topics/social_64.png>"} if ($a.subject -eq "drm"){$subjecticon = "<img align=left vspace=2 hspace=5 src=https://a.fsdn.com/sd/topics/drm_64.png>"} if ($a.subject -eq "business"){$subjecticon = "<img align=left vspace=2 hspace=5 src=https://a.fsdn.com/sd/topics/business_64.png>"} if ($a.subject -eq "games"){$subjecticon = "<img align=left vspace=2 hspace=5 src=https://a.fsdn.com/sd/topics/games_64.png>"} if ($a.subject -eq "china"){$subjecticon = "<img align=left vspace=2 hspace=5 src=https://a.fsdn.com/sd/topics/china_64.png>"} if ($a.subject -eq "tv"){$subjecticon = "<img align=left vspace=2 hspace=5 src=https://a.fsdn.com/sd/topics/tv_64.png>"} if ($a.subject -eq "medicine"){$subjecticon = "<img align=left vspace=2 hspace=5 src=https://a.fsdn.com/sd/topics/medicine_64.png>"} $html = New-Object -ComObject "HTMLFile" $html.IHTMLDocument2_write($a.description) $text = $html.body.innertext [System.Runtime.Interopservices.Marshal]::ReleaseComObject($html)|out-null $a.about = ("<table><tr><td><h3>" + $subjecticon + $title + "</h3><b>" + $comments + "</b> comments <b><i>(" + $department + ")</b></i></td></tr></table><table><tr><td style='font-family: Arial, sans-serif;font-size:13;'>" + $text + "</td></tr></table><hr>") } $SMTPServer = "smtp.gmail.com" $SMTPPort = "587" $Username = "myemail@gmail.com" $Password = "mypassword" $to = "recipient@somemail.com" $subject = ("Slashdot - " + (get-date).tolongdatestring()) $body = $articles.about $message = New-Object System.Net.Mail.MailMessage $message.subject = $subject $message.body = $articles.about $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)
PowerShell: Invoke-WebRequest Techspot RSS Feed Emailer
Follow the code below to receive emails from Techspot using their RSS feed:
[xml]$techspot = iwr https://www.techspot.com/backend.xml $articles = $techspot.getelementsbytagname('item') foreach ($a in $articles){ $link = $a.link $title = $a.title.'#cdata-section' $html = New-Object -ComObject "HTMLFile" $html.IHTMLDocument2_write($a.description.'#cdata-section') $imglink = $html.body.getelementsbytagname('img')[0].src $text = $html.body.innertext [System.Runtime.Interopservices.Marshal]::ReleaseComObject($html)|out-null $a.pubdate = ("<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><tr><td style='font-family: Arial, sans-serif;font-size:13;'>" + $text + "</td></tr></table><hr style='border: 2px solid mintcream;'>") } $SMTPServer = "smtp.gmail.com" $SMTPPort = "587" $Username = "myemail@gmail.com" $Password = "mypassword" $to = "recipient@somemail.com" $subject = ("Techspot - " + (get-date).tolongdatestring()) $message = New-Object System.Net.Mail.MailMessage $message.subject = $subject $message.body = $articles.pubdate $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)
PowerShell: Invoke-WebRequest Android Police RSS Feed Emailer
I like Android Police and used to have their mailer but it was quirky so I wrote a RSS Feed reader which then sends an email. I have it kick off daily via a scheduled task from my server and I get my daily dose.
[xml]$ap = iwr http://www.androidpolice.com/feed/ $articles = $ap.getelementsbytagname('item') foreach ($a in $articles){ $link = $a.link $comments = ($a.link + "#comments") $title = $a.title $title = $title -replace ('\[','"') $title = $title -replace ('\]','"') $html = New-Object -ComObject "HTMLFile" $description = ($a.description.'#cdata-section') $html.IHTMLDocument2_write($description) $imglink = $html.body.getelementsbytagname('img')[0].src $text = $html.body.innertext $text = $text -replace ('\[','"') $text = $text -replace ('\]','"') $text = $text -replace ('Read More\s+') $text = $text -replace ($title) $text = $text.replace(" was written by the awesome team at Android Police.","") $text = $text.trim() $text = $text + " <a href=$comments>Comments</a>" $a.pubdate = ("<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><tr><td style='font-family: Arial, sans-serif;font-size:13;'>" + $text + "</td></tr></table><hr style='border: 2px solid mintcream;'>") [System.Runtime.Interopservices.Marshal]::ReleaseComObject($html)|out-null } $SMTPServer = "smtp.gmail.com" $SMTPPort = "587" $Username = "myaccount@gmail.com" $Password = "mypassword" $to = "recipient@somemail.com" $subject = ("Android Police - " + (get-date).tolongdatestring()) $message = New-Object System.Net.Mail.MailMessage $message.subject = $subject $message.body = $articles.pubdate $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)
Subscribe to:
Posts (Atom)