我有一个outlook宏,可以读取所有未读电子邮件的所有主题行。
Sub ReadMails()
Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")
Set objFolder = objNamespace.GetDefaultFolder(olFolderInbox)
Set objFolderSrc = objFolder.Folders("My Own Folder")
Dim Subjects() As String
ReDim Subjects(1 To 1) As String
Set colItems = objFolderSrc.Items
Set colFilteredItems = colItems.Restrict("[UnRead] = False")
For Each objMessage In colFilteredItems
Subjects(UBound(Subjects)) = objMessage.ConversationTopic
ReDim Preserve Subjects(1 To UBound(Subjects) + 1) As String
Next
End Sub
相反,我需要阅读当天和当天早上8点之间发来的电子邮件。
如何添加该过滤器
答案 0 :(得分:0)
实施例
Option Explicit
Public Sub Example()
Dim EightAM As Date
EightAM = TimeValue("08:00:00 AM")
If (TimeValue(Now()) <= EightAM) Then
' Do something / Read Email
Debug.Print TimeValue(Now())
Else
' Do something else
Debug.Print "bla bla !!!"
End If
End Sub