前提・実現したいこと
powershellでOutlookにEWS接続し、未読メールを既読にするサンプルプログラムを作成しているのですが、
powershellもExchangeWebServicesも手探りの中コーディングしているため行き詰っております。
なんとか受信トレイの情報は取得できたのですが、受信トレイの中にあるメールが取得できずにいます。
メールが取得できれば「isRead=true」で既読にできると思うのですが…。
該当のソースコード
$DllPath = "C:\Program Files\Microsoft\Exchange\Web Services\2.2\Microsoft.Exchange.WebServices.dll"
$EwsUrl = "https://outlook.office365.com/EWS/Exchange.asmx"
$account = "XXXXXX@xxxxx"
$password = "PASSWORD"
$Assembly = [Reflection.Assembly]::LoadFile($DllPath)
if ($Assembly -eq $null) {
exit
}
$creds = New-Object System.Net.NetworkCredential($account,$password)
$Service = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService([Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2013_SP1, $TimeZone)
$Service.Url = New-Object System.Uri($EwsUrl)
$Service.Credentials = $creds
$Inbox = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($Service, [Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Inbox)
-- 以下で受信トレイの未読件数は取得できたが、この先のメール取得ができない…。
$inbox.UnreadCount
あなたの回答
tips
プレビュー