###########Define Variables########
$fromaddress = "donotreply@labtest.com"
$toaddress = "Aishwarya.Rawat@labtest.com"
$bccaddress = "Vikas.sukhija@labtest.com"
$CCaddress = "Mahesh.Sharma@labtest.com"
$Subject = "ACtion Required"
$body = get-content .\content.htm
$attachment = Get-ChildItem C:\sendemail -Filter *.txt | Sort-Object -Property LastWriteTime -Descending | Select-Object -First 1 -ExpandProperty FullName
$smtpserver = "smtp.labtest.com"
Send-MailMessage -From $fromaddress -To $toaddress -Bcc $bccaddress -Cc $CCaddress -Body $body -Attachments $attachment -SmtpServer $smtpserver
####################################
$body = get-content .\content.htm -Raw
Open in new window