2013-10-25 52 views
0

如何接受確認自動在PowerShell中的Outlook 我有腳本出口附件從Outlook電子郵件 - 見下 它正常工作在一臺PC上,但另一臺PC上有一個問題: 展望給出了消息,並希望回答:如何自動接受確認在PowerShell中的Outlook

   Permit   Denny   Help 

如果我手動點擊許可證或丹尼它工作正常。我想自動化它。 你能給我一些建議如何在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 ----------------------------------> 

回答

0

安全提示是由Outlook的最新版本顯示,如果沒有找到本地系統上跟上時代的反病毒產品。

如果僅限於PowerShell,並且無法使用C++或Delphi來使用擴展MAPI,則Redemption是另一種選擇。

0

我發現安全提示行 「$ SenderName = $ _。SenderName」產生 真的我不需要使用SenderName,我刪除了這一行。 現在,腳本可以正常工作,沒有任何消息。