$Subject="test" $MailTo="xx@mail.com" try { #每个指令后面都得加上 -ErrorAction Stop Copy-Item \xx1kk d: -ErrorAction Stop Copy-Item \xx2kk d: -ErrorAction Stop } catch{ #-Encoding utf7是为了防止中文乱码 Send-MailMessage -From SDS@quantacn.com -To $MailTo -Subject $Subject -SmtpServer 10.10.20.30 -Body "FailedItem:$_.Exception.ItemName" -Encoding utf7 }