Ich versuche, ein Skript zu erstellen, um automatisch eine E-Mail mit verschiedenen Anhängen zu senden. Ich habe ein Problem, dass die Datei nicht gefunden wird. Ich kann bestätigen, dass die Datei in dem Ordner vorhanden ist. Ich bin mir nicht sicher, warum ich diesen Fehler bekomme und habe versucht, das Skript auf verschiedenen Plattformen auszuführen, weil ich dachte, dass es ein Problem sein könnte, wo der Code läuft, aber bis jetzt hat noch nichts funktioniert. Jede Hilfe würde sehr geschätzt werden.Powershell E-Mail-Anhang
Param (
$Path = "\\cottonwood\users\Shared\Pool Acquisitions",
$SMTPServer = "mail.genericmail.com",
$From = "[email protected]",
#The below commented out line is used to test with just one individual. Be sure to comment out the one with all individuals before troubleshooting.
#$To = @("[email protected]"),
$SMTPport = "587",
$To = @("[email protected]"),
$Subject = "Folders Added in",
$logname = "\\cottonwood\users\Shared\Loan Documents - Active\logs\New Folders$date.txt",
$date = (Get-Date -Format MMddyyyy),
$SMTPBody = "body",
$files = (Get-ChildItem "\\cottonwood\users\IT\Missing Folder Location")
)
$SMTPMessage = @{
To = $To
From = $From
Subject = "$Subject $Path"
Smtpserver = $SMTPServer
Port = $SMTPport
}
$attachment = $files
$SMTPBody = "`nThe following folders have been found to be non-existant in the last 24 hours:`n`n"
Send-MailMessage @SMTPMessage -Body $SMTPBody -Attachments $attachment