Hi @Wu Yuki ,
You can check the csv file like below
if(Get-Content $FileName){
send-MailMessage -From xxxxx@abc.com -to xxxxx@abc.com -Subject "XXX_Check" -Body $mailbody -attachment $FileName -SmtpServer smtp.XXX.com -Encoding Unicode
}
else{
Write-Host 'The csv file has no data in it.'
}
Best Regards,
Ian Xue
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.