簡體   English   中英

發送PowerShell后刪除電子郵件附件

[英]Delete email attachment after sending powershell

我使用PowerShell編寫了一個自動電子郵件腳本。

然而,電子郵件發送如何配置它,以便附加的文件移動到它最初所在的文件夾內的另一個文件夾?

#Searches dir for list , formats 
$Attachment = Get-ChildItem -Path $dir -Filter "*$($Region.name)*" -Recurse
$AttachmentName = $Attachment.BaseName

$Subject = "$AttachmentName @ $Time"
$Body = "Please find attached the file needed for $($Region.name). 

Regards,
Me
"
#Actions Email
Send-MailMessage -From $Region.From -To $Region.To -CC $Region.Cc -Subject $Subject -Body $Body -SmtpServer $SMTPServer -Attachments $Attachment.FullName
Move-Item Get-ChildItem -Path $dir -Filter "*$($Region.name)*" -Recurse "C:\Users\users\Desktop\MissingImageLists\OldLists"
}

刪除Move-Item命令並將其替換為:

$Attachment | Move-Item -Destination "$dir\subfolder"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM