Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Sub ListMail()
Dim olApp As Outlook.Application
Dim olNS As NameSpace
Dim olRecItems As Outlook.MAPIFolder
Dim olFilterRecItems As Items
Dim olNewMail As Outlook.MailItem
Dim strFilter As String
Dim dteLastCheck As Date
Dim dteThisCheck As Date
Dim strNewMessage As String
Dim i
'Dates to illustrate filter
dteLastCheck = DateAdd("d", -30, Now())
dteThisCheck = Now()
Set olApp = CreateObject("Outlook.Application")
Set olNS = olApp.GetNamespace("MAPI")
Set olRecItems = olNS.GetDefaultFolder(olFolderInbox)
'Note that there are no seconds in the filter and that
'the dates are text
strFilter = "[ReceivedTime] > " _
& Chr(34) & Format(dteLastCheck, "mm/dd/yyyy hh:nn") & Chr(34) _
& " AND [ReceivedTime] < " _
& Chr(34) & Format(dteThisCheck, "mm/dd/yyyy hh:nn") & Chr(34)
Set olFilterRecItems = olRecItems.Items.Restrict(strFilter)
For i = 1 To olFilterRecItems.count
Debug.Print _
olFilterRecItems(i).ReceivedTime & vbCrLf _
& olFilterRecItems(i).EntryID & vbCrLf _
& olFilterRecItems(i).Body & vbCrLf
Next
End Sub