发送PowerShell后删除电子邮件附件

时间:2017-04-26 16:59:09

标签: windows 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"
}

1 个答案:

答案 0 :(得分:0)

删除ls命令并将其替换为:

Move-Item