Ok, this may have been answered, but I\'m new and trying to learn, so I guess I\'m not \"getting\" it. I have a variable that contains a table of information (I got it from
Here's how I'd do it:
# Create a DataTable
$table = New-Object system.Data.DataTable "TestTable"
$col1 = New-Object system.Data.DataColumn Name,([string])
$col2 = New-Object system.Data.DataColumn Dept,([string])
$table.columns.add($col1)
$table.columns.add($col2)
# Add content to the DataTable
$row = $table.NewRow()
$row.Name = "John"
$row.Dept = "Physics"
$table.Rows.Add($row)
$row = $table.NewRow()
$row.Name = "Susan"
$row.Dept = "English"
$table.Rows.Add($row)
# Create an HTML version of the DataTable
$html = "Name Dept "
foreach ($row in $table.Rows)
{
$html += "" + $row[0] + " " + $row[1] + " "
}
$html += "
"
# Send the email
$smtpserver = "smtpserver.domain.com"
$from = "user@domain.com"
$to = "user@domain.com"
$subject = "test"
$body = "Hi there,
Here is a table:
" + $html
Send-MailMessage -smtpserver $smtpserver -from $from -to $to -subject $subject -body $body -bodyashtml