Lucas Lichte
New Member
- Outlook version
- Outlook 2013 32 bit
- Email Account
- Office 365 Exchange
I'm trying to check for the absence of an email in a folder. I have a bot sending to this folder every 15 minutes. I want to check every 30 minutes to see if I've gotten an email in the last 30 minutes, and if I haven't, pop up a message box. The problem I'm running into is that I can't figure out how VBA for Outlook does Dates, and I can't find a reference.
The called Macro I'm trying to write is:
Sub Check_GWAAR()
Dim myOlItems As Object
Dim compareDate As Date
Dim sentDate As Date
Set myOlItems = Outlook.Session.GetDefaultFolder(olFolderInbox).Folders("Test@GWAAR").Items
Set compareDate = DateAdd("m", -30, Now)
Set sentDate = myOlItems.Items(1).ReceivedTime
If sentDate < compareDate Then MsgBox ("Check the GWAAR Test VM!")
End Sub
It's telling me that the variables need to be set to objects. When I set them to objects, it tells me the Set statements don't evaluate to objects.
Help?
The called Macro I'm trying to write is:
Sub Check_GWAAR()
Dim myOlItems As Object
Dim compareDate As Date
Dim sentDate As Date
Set myOlItems = Outlook.Session.GetDefaultFolder(olFolderInbox).Folders("Test@GWAAR").Items
Set compareDate = DateAdd("m", -30, Now)
Set sentDate = myOlItems.Items(1).ReceivedTime
If sentDate < compareDate Then MsgBox ("Check the GWAAR Test VM!")
End Sub
It's telling me that the variables need to be set to objects. When I set them to objects, it tells me the Set statements don't evaluate to objects.
Help?