0
我想创建一个脚本来自动发送带有各种附件的电子邮件。我有一个问题说它没有找到该文件。我可以确认该文件存在于该文件夹中。我不确定为什么我得到这个错误,并试图在各种平台上运行脚本,认为它可能是代码运行的问题,但目前还没有任何工作。任何帮助将不胜感激。Powershell电子邮件附件
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