2016-05-04 19 views
1

ローカルのOutlookクライアントを自動化するためにPowerShellを使用するいくつかのソリューションがありましたが、これをサーバー側で実行してください。特定のアカウントでサーバーにアクセスし、未読メッセージを確認し、ファイル共有に添付ファイルを保存し、読み取ったメッセージに印を付けます。電子メールの添付ファイルをOffice 365からPowerShellのファイル共有に保存できますか?

答えて

0

あなたはExchange環境にいますか?その場合、Exchange Webサービスはオプションのネットワークに公開されます。

+0

私たちはハイブリッドなExchange環境です。私はEWSを読み込もうとしていますが、接続してメールボックスから電子メールをプルダウンするための素早く汚れたPowerShellがあれば、大きな助けになるでしょう。 – Keith

+0

ああ、私は動作しているコードをいくつか見つけました。添付ファイルを取り除くことができるかどうかを確認する。 – Keith

0

これには、Exchange Managed Services APIがインストールされている必要があります。

$ewsPath = "C:\Program Files\Microsoft\Exchange\Web Services\2.2\Microsoft.Exchange.WebServices.dll" 
Add-Type -Path $ewsPath 

$ews = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService 
$cred = (Get-Credential).GetNetworkCredential() 
$ews.Credentials = New-Object System.Net.NetworkCredential -ArgumentList $cred.UserName, $cred.Password, $cred.Domain 
$ews.AutodiscoverUrl("[email protected]", {$true}) 
$results = $ews.FindItems(
    "Inbox", 
    (New-Object Microsoft.Exchange.WebServices.Data.ItemView -ArgumentList 100) 
) 
$MailItems = $results.Items | where hasattachments 

foreach ($MailItem in $MailItems){ 

    $MailItem.Load() 

    foreach($Attachment in $MailItem.Attachments){ 
     $Attachment.Load() 
     $File = new-object System.IO.FileStream(("C:\Temp\” + $attachment.Name.ToString()), [System.IO.FileMode]::Create) 
     $File.Write($attachment.Content, 0, $attachment.Content.Length) 
     $File.Close() 
    } 
} 
関連する問題