Ich habe ein PowerShell-Skript geschrieben, das eine E-Mail erstellt, aber ich kann keine Datei anhängen. Die Datei existiert und PowerShell kann sie öffnen. Könnte mir jemand sagen, was ich falsch mache?So hängen Sie eine Datei an eine E-Mail mit PowerShell an
$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)
auch, dass ich mit Powershell 2 – TheLukeMcCarthy