2017-07-07 22 views
0

さまざまな添付ファイルを含む電子メールを自動的に送信するスクリプトを作成しようとしています。そのファイルが見つからないという問題が発生しています。ファイルがフォルダ内に存在することを確認できます。私はなぜこのエラーが発生しているのか不明で、さまざまなプラットフォームでスクリプトを実行しようとしましたが、コードが実行されている場所の問題かもしれないと思っていますが、まだ何も動いていません。どんな助けでも大歓迎です。Powershell電子メールの添付ファイル

$files = (Get-ChildItem "\\cottonwood\users\IT\Missing Folder Location") 

へ:

$files = (Get-ChildItem "\\cottonwood\users\IT\Missing Folder Location").fullname 
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 

答えて

0

Send-MailMessage

は、完全なファイルパス

変更に含まれていない変数$filesなどのファイルを見つけることができません

関連する問題