0

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

2 に答える 2

0

セキュリティ プロンプトが " $SenderName = $_.SenderName " 行で生成されることがわかりました。SenderName を使用する必要はありません。この行を削除しました。これで、スクリプトはメッセージなしで正常に動作します。

于 2013-10-29T09:51:27.103 に答える
0

最新バージョンの Outlook では、ローカル システムで最新のウイルス対策製品が見つからない場合、セキュリティ プロンプトが表示されます。

PowerShell に限定されており、C++ または Delphi を使用して拡張 MAPI を使用できない場合は、Redemptionが別のオプションです。

于 2013-10-25T14:38:36.207 に答える