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 ---------------------------------->