@stess
@scottalanmiller
I got one script for copying the excel sheet content to the mail body which have issue in it.The issue where the table is not copying to body only contents are copied to the mail body without table.Help needed
$email = "
[email protected]"
$smtpServer = "mail.somecompany.com"
$ForEmail = @()
######################################
#Create and get my Excel Obj
$x1 = New-Object -comobject Excel.Application
$UserWorkBook = $x1.Workbooks.Open("C:\temp\bluenose.xlsx")
#Select first Sheet
$UserWorksheet = $UserWorkBook.Worksheets.Item(1)
$UserWorksheet.activate()
#Copy the part of the sheet I want in the Email
$rgeSource=$UserWorksheet.range("A1","E20")
$rgeSource.Copy() | out-null
$Results = Get-Clipboard
foreach ($Result in $Results)
{
$ForEmail += "$Result<br>"
}
######################################
$msg = new-object Net.Mail.MailMessage
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$msg.From = "
[email protected]"
$msg.To.Add($email)
$msg.Subject = "Excel Pasted"
$msg.IsBodyHtml = $True
$msg.Body = "Here is the contents of the excel file<br>
<br>
$ForEmail
<br>
"
$smtp.Send($msg)](![image url](image url))