Update Outlook inbox folder

◇◆丶佛笑我妖孽 提交于 2019-12-22 00:26:14

问题


I would like to update (sync) the inbox folder (send/receive) before running this PowerShell script that gets the e-mails, but I don't know how. Is there a way to do this from powershell?

$matchString= "support@blabla.com";
$olFolderInbox = 6
$outlook = New-Object -COM Outlook.Application;
$mapi = $outlook.GetNameSpace("MAPI");
$inbox = $mapi.GetDefaultFolder($olFolderInbox)

$inbox.Items | where { $_.SenderEmailAddress -match $matchString } |
    Select SenderEmailAddress,to,subject |
    Format-Table -AutoSize 

回答1:


This is how you do that:

$mapi.SendAndReceive($false)

Also, for me I needed to use the Logon method before the SendAndReceive:

$mapi.logon()

Check the link for more reference.



来源:https://stackoverflow.com/questions/40579409/update-outlook-inbox-folder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!