hey guys,
I have a camera at work that records for 30sec whenever it detects movement and then sends me an email.
The problem is that during the day it sends me about 500 mails that i really don't need and there's no way to time the motion detection on the camera it's self.
So, I've written the code below but I'm having issue moving the mail to a different folder once completed.
Can anyone tell me how to get get the mails moved to a different folder and mark it as read??
I've tried googling bu it hasn't helped.
Cheers in advance!!
I have a camera at work that records for 30sec whenever it detects movement and then sends me an email.
The problem is that during the day it sends me about 500 mails that i really don't need and there's no way to time the motion detection on the camera it's self.
So, I've written the code below but I'm having issue moving the mail to a different folder once completed.
Code:
Public WithEvents myOlItems As Outlook.Items
Public Sub Application_Startup()
' Reference the items in the Inbox. Because myOlItems is declared
' "WithEvents" the ItemAdd event will fire below.
Set myOlItems = Outlook.Session.GetDefaultFolder(olFolderInbox).Items
End Sub
Private Sub myOlItems_ItemAdd(ByVal Item As Object)
MsgBox "mail has arrived"
' If it's currently not between 9:00 A.M. and 5:00 P.M.
If Time() > #7:30:00 AM# Or Time() < #5:30:00 PM# Then
MsgBox "mail arrived within office hours"
' Check to make sure it is an Outlook mail message, otherwise
' subsequent code will probably fail depending on what type
' of item it is.
If TypeName(Item) = "MailItem" Then
MsgBox "testing to see if mail is from camera"
If Item.SenderEmailAddress = "[email protected]" Then
MsgBox "mail from [email protected]"
myfolder = "Back Door Camera"
' Move message to folder and mark as read.
MailItem.Move myfolder
MailItem.markas Read
End If
End If
End If
MsgBox "end of VBA script"
End Sub
Can anyone tell me how to get get the mails moved to a different folder and mark it as read??
I've tried googling bu it hasn't helped.
Cheers in advance!!