Windows 发送powershell后删除电子邮件附件

Windows 发送powershell后删除电子邮件附件,windows,powershell,Windows,Powershell,我已经使用powershell为自动电子邮件编写了一个脚本 但是,电子邮件会发送,我如何配置它,以便将附加的文件移动到它原来所在的文件夹中的另一个文件夹 #Searches dir for list , formats $Attachment = Get-ChildItem -Path $dir -Filter "*$($Region.name)*" -Recurse $AttachmentName = $Attachment.BaseName $Subject = "$Attachment

我已经使用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"