我想问一下是否有人有现成的片段或可以提供一个可以执行以下操作的工作片段:
VBA 或 powershell 脚本,用于根据日期范围从已发送项目及其所有子文件夹中提取电子邮件详细信息(发件人、收件人、主题、时间戳)
我想问一下是否有人有现成的片段或可以提供一个可以执行以下操作的工作片段:
VBA 或 powershell 脚本,用于根据日期范围从已发送项目及其所有子文件夹中提取电子邮件详细信息(发件人、收件人、主题、时间戳)
Outlook 对象模型对所有编程语言都是通用的,因此我希望您能够将以下说明应用于 PS 脚本。
有几种方法可以在 Outlook 中正确完成工作。
Find
/ FindNext
orRestrict
方法来获取与您的搜索条件相对应的项目集合,然后遍历所有这些集合。在以下文章中阅读有关这些方法的更多信息:Table
并获得一个新Table
对象。该Filter
参数是对在 parent 中表示为行的项的指定属性的查询Table
。该查询使用 Microsoft Jet 语法或 DAV 搜索和定位 (DASL) 语法。例如,以下 Jet 过滤器和 DASL 过滤器为ReceivedTime
2021 年 12 月 12 日下午 3:30 之前的项目指定相同的条件:criteria = "[ReceivedTime] < '" & Format$("12/12/2021 3:30PM","General Date") & "'"
例如:
Sub RestrictTable()
'Declarations
Dim Filter As String
Dim oRow As Outlook.Row
Dim oTable As Outlook.Table
Dim oFolder As Outlook.Folder
'Get a Folder object for the Inbox
Set oFolder = Application.Session.GetDefaultFolder(olFolderSentItems)
'Define Filter to obtain items last modified after November 1, 2005
Filter = "[ReceivedTime] > '12/12/2021'"
'Restrict with Filter
Set oTable = oFolder.GetTable(Filter)
'Enumerate the table using test for EndOfTable
Do Until (oTable.EndOfTable)
Set oRow = oTable.GetNextRow()
Debug.Print (oRow("EntryID"))
Debug.Print (oRow("Subject"))
Debug.Print (oRow("CreationTime"))
Debug.Print (oRow("LastModificationTime"))
Debug.Print (oRow("MessageClass"))
Loop
End Sub