我的powershell腳本目前處理髮送電子郵件從命令行到用戶列表。我想添加一個附件到電子郵件和一個Cc列表,所以所有的電子郵件都不通過「收件人」電子郵件參數。這是我目前的功能。添加附件和抄送參數smtp電子郵件功能
function SendEmail
{
$smtpServer = "smtp.server"
$smtpFrom = "PROD <[email protected]>"
$smtpTo = "[email protected]"
$messageSubject = "Weekly List "+$day
$messagebody = "Hi User, Please find attached document. Thank you."
$smtp = New-Object Net.Mail.SmtpClient($smtpServer)
$smtp.Send($smtpFrom,$smtpTo,$messageSubject,$messagebody)
}
我的嘗試是增加一個變量,名爲$連接=「\ PathtoFile」 並添加附件$進入發送功能,但沒有工作...
你不使用'發送-MailMessage' cmdlet的任何特別的原因? –
我在向主題添加日期變量時遇到了問題,並且在使用Send-mailmessage cmdlet時,還遇到了諸如「'」的電子郵件正文中的特殊字符。 – rafacardosoc