J'ai écrit un script PowerShell qui va créer un email, mais je n'arrive pas à joindre un fichier. Le fichier existe et PowerShell peut l'ouvrir. Quelqu'un pourrait-il me dire ce que je fais de mal?Comment joindre un fichier à un e-mail avec 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)
J'utilise aussi Powershell 2 – TheLukeMcCarthy