问题
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