【问题标题】:Powershell get email content by datePowershell 按日期获取电子邮件内容
【发布时间】:2017-04-17 02:51:03
【问题描述】:

我发现下面的脚本可以通过powershell获取邮件内容:

Add-Type -Assembly "Microsoft.Office.Interop.Outlook"
$Outlook = New-Object -ComObject Outlook.Application
$namespace = $Outlook.GetNameSpace("MAPI")
$inbox = $namespace.GetDefaultFolder([Microsoft.Office.Interop.Outlook.OlDefaultFolders]::olFolderRssFeeds)
$inbox.Items | Format-Table SenderName, To, CC, ReceivedTime,  Subject, Body
  1. 但是如何按日期过滤。喜欢希望收到今天的电子邮件吗? (频率应为 1 天或半天)
  2. 如何按主题过滤?
  3. 对于[Microsoft.Office.Interop.Outlook.OlDefaultFolders]::olFolderRssFeeds),把默认文件夹改成自己创建的文件夹可以吗?

【问题讨论】:

  • 你试过什么?理想情况下,您还应该避免一次问多个问题。

标签: powershell date email filter directory


【解决方案1】:

对于 Q1 和 Q2,可以使用 where-object 过滤答案:

过滤内容:| where-object { $_.Subject -ilike "错误"}

过滤日期:| where-object { $_.ReceivedTime -gt "$date"}

Q3,还是找不到答案

【讨论】:

    【解决方案2】:

    对于您的 Q3,您可以使用以下命令从特定文件夹获取邮件

    $Namespace.Folders.Item(1).Folders.Item('your folder name').Items
    

    【讨论】:

      猜你喜欢
      • 2012-05-29
      • 1970-01-01
      • 1970-01-01
      • 2012-09-24
      • 2012-04-15
      • 1970-01-01
      • 2013-04-05
      • 2015-09-25
      • 1970-01-01
      相关资源
      最近更新 更多