Skip to content

Instantly share code, notes, and snippets.

@smaug9
Created February 21, 2019 16:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smaug9/1b17130e8ba73222b71d54199d39f70a to your computer and use it in GitHub Desktop.
Save smaug9/1b17130e8ba73222b71d54199d39f70a to your computer and use it in GitHub Desktop.
send-htmltable
#send-htmltable.ps1
[CmdletBinding()]
param (
[Parameter(
Mandatory = $true,
ValueFromPipeline = $true,
#ValueFromPipelineByPropertyName = $true,
Position = 0)]
[ValidateNotNullOrEmpty()]
#[alias("name")]
[pscustomobject]
$inputobject,
[string]
$subject = "TPS Report"
)
begin {
write-verbose "begin block"
#$body = @()
#$results = @()
if (!$CSS){
$CSS = @"
<style type="text/css">
table {
font-family: Verdana;
border-style: dashed;
border-width: 1px;
border-color: #FF6600;
padding: 5px;
background-color: #FFFFCC;
table-layout: auto;
text-align: center;
font-size: 8pt;
}
table th {
border-bottom-style: solid;
border-bottom-width: 1px;
font: bold
}
table td {
border-top-style: solid;
border-top-width: 1px;
}
.style1 {
font-family: Courier New, Courier, monospace;
font-weight:bold;
font-size:small;
}
</style>
"@
}#End if
$HTMLDetails = @{
Title = $subject
Head = $CSS
}
}
process {
write-verbose "process block"
#$body += $inputobject
$body = foreach ($obj in $inputobj) {
}
}
end {
write-verbose "end block"
$smtpargs = @{
to = "me@asdf.com"
from = "me@asdf.com"
subject = $subject
smtpserver = "mail.google.com"
#body = "Body01"
#body = $results | ? {$_.encrypted -eq $false} | sort cluster, vmname | ConvertTo-Html @HTMLDetails | out-string
body = $body | ConvertTo-Html @HTMLDetails | out-string
bodyashtml = $true
} #end $smtpargs
Send-MailMessage @smtpargs
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment