2016-03-24 50 views
0
#file path 
$filepath = “c:\test\” 


#set outlook to open 
$o = New-Object -comobject outlook.application 
$n = $o.GetNamespace(“MAPI”) 


#you'll get a popup in outlook at this point where you pick the folder you want to scan 
$f = $n.pickfolder() 

#date string to search for in attachment name 
$date = Get-Date -Format yyyyMMdd 


#now loop through them and grab the attachments 
$f.Items | foreach { 
    $_.attachments | foreach { 
    Write-Host $_.filename 
    $a = $_.filename 
    If ($a.Contains($date)) { 
    $_.saveasfile((Join-Path $filepath $a)) 
     } 
    } 
} 

実際に実行してホストに書き込みますが、添付ファイルはドライブのフォルダには表示されません。Outlookのサブフォルダ添付ファイルの保存 - powershell COM

おかげで、あなただけのスクリプトをコピーしたhaventはそれだけで、これはあなたがすべての添付、保存したい場合はどうなるのかである名前はYYYYMMDD形式で現在の日付が含まれているの添付を節約気づいたと仮定すると、

答えて

0

#file path 
$filepath = “c:\test\” 


#set outlook to open 
$o = New-Object -comobject outlook.application 
$n = $o.GetNamespace(“MAPI”) 


#you'll get a popup in outlook at this point where you pick the folder you want to scan 
$f = $n.pickfolder() 

#now loop through them and grab the attachments 
$f.Items | foreach { 
    $_.attachments | foreach { 
    Write-Host $_.filename 
    $a = $_.filename 
    $_.saveasfile((Join-Path $filepath $a)) 
    } 
} 
+0

ありがとう、すべての後に私は役に立たない取得日を削除しませんでした。私は基本的に電子メールをサブフォルダに送信したいと思っていますが、各添付ファイルはサブフォルダ内にあるので印刷します。これを行う方法はありますか? – Royston

+0

@Royston私はあなたがディレクトリにイベントハンドラを登録し、それらの方法で印刷することができますが、あなたが自分自身を把握する必要がありますようにOutlookに安全なファイルをフォルダにする方法を見つけることができる場合は知っている。しかし、これはトピックの範囲外です。私の答えがあなたの質問を解決したら、それを受け入れることを忘れないでください。 – Paul

関連する問題