Created
July 7, 2013 18:54
-
-
Save najamsk/5944515 to your computer and use it in GitHub Desktop.
this function will take emails objects and loop through them to create html page listing.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function EmailLogReport ($mails, $filepath) | |
{ | |
cls; | |
$file = $filepath | |
$mails = $mails | sort ReceivedTime -Descending | |
$hHeader = "<!DOCTYPE html><html><head><link href='screenLog.css' rel='stylesheet' type='text/css' /></head><body>" | |
$hHeader >> $file | |
"<div class='mails'>" >> $file | |
foreach($mail in $mails) | |
{ | |
$divC = "</div>" | |
$mH = "<div class='mail'><div class= 'head'>" | |
$bodyh = "<div class='message'>" | |
$mH >> $file | |
$counter = ($counter + 1) | |
$counterH = "<p class='counter hItem'>#" + $counter + ". </p>" | |
write-host $counterH | |
$counterH >> $file | |
$subject = "<p class='hItem subject'>subject = " + $mail.subject + "</p>" | |
write-host $subject | |
$subject >> $file | |
$from = "<p class='hItem from'>From = " + $mail.SenderEmailAddress + "</p>" | |
write-host $from | |
$from >> $file | |
$received = "<p class='hItem ReceivedTime'>Received at = " + $mail.ReceivedTime + "</p>" | |
write-host $received | |
$received >> $file | |
$to = "<p class='hItem to'>To = " + $mail.To + "</p>" | |
write-host $to | |
$to >> $file | |
$cc = "<p class='hItem cc'>CC = " + $mail.cc + "</p>" | |
write-host $cc | |
$cc >> $file | |
$bcc = "<p class='hItem bcc'>BCC = " + $mail.bcc + "</p>" | |
write-host $bcc | |
$bcc >> $file | |
$divC >> $file | |
write-host "--------------------------------------------------------------------------------------------------------------" | |
write-host "" | |
$bodyh >> $file | |
#$body = "<div class='body'>" + $mail.body + "</div>" | |
#write-host $body | |
#$body >> $file | |
$body = "<div class='body'>" + $mail.HTMLBody + "</div>" | |
write-host $body | |
$body >> $file | |
$divc >> $file | |
$divc >> $file | |
write-host "" | |
write-host "**************************************************************************************************************" | |
write-host "" | |
} | |
"</div>" >> $file | |
$hfooter = "</html></body>" | |
write-host "end" | |
} | |
cls; | |
EmailLogReport $myLog "d:\jul13.html" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment