如何在 Outlook 的 PowerShell 中自动接受确认我有从 Outlook 的电子邮件中导出附件的脚本 - 请参阅下一个它在一台 PC 上正常工作,但在另一台 PC 上存在问题:Outlook 给出消息并希望得到答案:
Permit Denny Help
如果我手动单击 Permit 或 Denny 它可以正常工作。我想自动化它。你能给我一些建议如何在PowerShell中做到这一点吗?我尝试将 Outlook 设置为不发送此消息,但没有成功。我的脚本:
# <-- Script --------->
# script works with outlook Inbox folder
# check if email have attachments with ".txt" and save those attachments to $filepath
# path for exported files - attachments
$filepath = "d:\Exported_files\"
# create object outlook
$o = New-Object -comobject outlook.application
$n = $o.GetNamespace("MAPI")
# $f - folder „dorucena posta“ 6 - Inbox
$f = $n.GetDefaultFolder(6) # 6 - Inbox
# select newest 10 emails, from it olny this one with attachments
$f.Items| select -last 10| Where {$_.Attachments}| foreach {
# process only unreaded mail
if($_.unread -eq $True) {
# processed mail set as read, not to process this mail again next day
$_.unread = $False
$SenderName = $_.SenderName
Write-Host "Email from: ", $SenderName
# process all attachments
$_.attachments|foreach {
$a = $_.filename
If ($a.Contains(".txt")) {
Write-Host $SenderName," ", $a
# copy *.txt attachments to folder $filepath
$_.saveasfile((Join-Path $filepath "$a"))
}
}
}
}
Write-Host "Finish"
# <------ End Script ---------------------------------->