【问题标题】:Update Outlook inbox folder更新 Outlook 收件箱文件夹
【发布时间】:2016-11-14 15:12:26
【问题描述】:

我想在运行获取电子邮件的 PowerShell 脚本之前更新(同步)收件箱文件夹(发送/接收),但我不知道如何操作。有没有办法从 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 

【问题讨论】:

  • 您使用的是哪个版本的 Outlook?因为即使我能够运行 $mapi.SendAndReceive($false)

标签: powershell outlook powershell-3.0


【解决方案1】:

你就是这样做的:

$mapi.SendAndReceive($false)

另外,对我来说,我需要在 SendAndReceive 之前使用 Logon 方法:

$mapi.logon()

Check the link for more reference.

【讨论】:

  • 我收到一个错误:“方法调用失败,因为 [System.__ComObject] 不包含名为 'SendAndReceive' 的方法。”
  • 你用的是什么版本?
  • @4c74356b41 是否可以对单个邮箱执行相同操作?
  • 对不起,现在没有outlook,无法查看
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-02-22
  • 2016-09-28
  • 1970-01-01
  • 2018-05-08
  • 2019-03-17
  • 2017-03-15
  • 1970-01-01
相关资源
最近更新 更多