我已經編寫了一個PowerShell腳本來創建電子郵件,但是我似乎無法附加文件。該文件確實存在,PowerShell可以打開它,任何人都可以告訴我我做錯了什麼?如何使用PowerShell將文件附加到電子郵件
$ol = New-Object -comObject Outlook.Application
$message = $ol.CreateItem(0)
$message.Recipients.Add("Deployment")
$message.Subject = "Website deployment"
$message.Body = "See attached file for the updates made to the website`r`n`r`nWarm Regards`r`nLuke"
# Attach a file this doesn't work
$file = "K:\Deploy-log.csv"
$attachment = new-object System.Net.Mail.Attachment $file
$message.Attachments.Add($attachment)
另外我使用PowerShell 2 – TheLukeMcCarthy 2010-10-22 13:54:27