Help with code to move mail on receipt to another folder based on time received

Status
Not open for further replies.

Doug Horton

New Member
Outlook version
Outlook 2013 32 bit
Email Account
Exchange Server
I have a motion sensing security camera in my server room. It sends a mail message with a snapshot any time motion is detected. I'm trying to create a rules script that moves those messages received between the hours of 6am and 6pm to another folder (so I don't have to see them in my inbox during the day).

The following VBA code was created for this purpose:

Sub ProcessServerCamMail(Item As Outlook.MailItem)
Dim strFolder As String
Dim rectime As Date

rectime = TimeValue(Item.ReceivedTime)
strFolder = "ServerCams"

If rectime > TimeValue("6:00 am") And rectime < TimeValue("6:00 pm") Then
Item.Move Session.GetDefaultFolder(olFolderInbox).Folders(strFolder)
End If​

End Sub​

The problem I am having is that this only works if the destination folder is a subfolder under "Inbox". However, my subfolder is at the same level as Inbox. In other words, it's a subfolder of the mailbox, not Inbox.

How can I modify this to work with "ServerCams" folder at the same level as my Inbox?

We are using Exchange 2007 and Outlook 2013.

Thanks,
Doug.
 
Status
Not open for further replies.
Thread starter Similar threads Forum Replies Date
R [VBA] complicated(?) outlook events - need help with code Using Outlook 15
C Need Help with Simple Code Correction Using Outlook 11
M help correct code Using Outlook 0
M Updates to exchange server broke code - please help Using Outlook 2
T WAB editing: To help prevent malicious code from running.......... Using Outlook 18
S 0x800CCC33 error code. 'access to the account denied' 'server responded forbidden. Please help. Using Outlook 1
R Chat wants product code, no code matching the format of the example is on the box. Outlook does not delete downloaded email from the server, help is U Using Outlook 1
D Help Need Fix-Cant connect to server , then error's out - Synchornizing Sub Folders Error Code ox800cccoe Using Outlook 1
J Unable to send outgoing email. error code 0x800cccoe socket error 10013 port 25.please help Using Outlook 1
F No Attachment Warning - VBA Code HELP Outlook VBA and Custom Forms 1
S HELP: How do I code a button I created? Outlook VBA and Custom Forms 1
C Beginner Needs VBA Help in Modifying Code Outlook VBA and Custom Forms 2
S To help prevent malicious code from running, one or more objects in this form were not loaded. For m Outlook VBA and Custom Forms 1
R Disable conversation thread from replying of recipients in the same subject. Please help Using Outlook 0
R seperate read layout to design in outlook 2016..Help!! Outlook VBA and Custom Forms 3
O Help .. got lost ... installing Office like 2016 Using Outlook 5
A Arthur needs help with 2007 Outlook e-mail Using Outlook.com accounts in Outlook 3
R Help Revising VBA macro to delete email over different time span Outlook VBA and Custom Forms 0
Marc2019 Need help please! Cannot Setup my outlook email account on my Mac Outlook 2011 Using Outlook.com accounts in Outlook 2
L Attachment saving and tracking - PLEASE help! Outlook VBA and Custom Forms 5
I Help with dates in task list. Using Outlook 5
C need help setting up outlook first time Using Outlook 1
K To do bar help Using Outlook 8
M Help sending email but removing signature via VBA Outlook VBA and Custom Forms 5
S help with outlook scripting Outlook VBA and Custom Forms 4
J Help Please!!! Outlook 2016 - VBA Macro for replying with attachment in meeting invite Outlook VBA and Custom Forms 9
EmelineGueguen Help to understand the problem of work Using Outlook 1
N Outlook Forms Help Outlook VBA and Custom Forms 2
N Need help syncing contacts to iPhone X Using Outlook 8
S VBA Macro - Run-time error '424': object required - Help Please Outlook VBA and Custom Forms 3
broadbander Needing help with reply/reply all while keeping attachments and adding a new CC recipient. Outlook VBA and Custom Forms 5
J Help! My contacts have disappeared. Using Outlook 5
J HELP- Rule to auto strip prepend from external emails Using Outlook 0
J Help Needed With Multi-Step Login Email Address Using Outlook.com accounts in Outlook 1
G Bcc help - Preventing multiple forwards from a bcc'd distribution group Using Outlook 1
G [Help] Converting array to destination folder path Outlook VBA and Custom Forms 1
K Help.... Office Outlook 2016 Using Outlook 1
S Error using AddressEntry.GetContact - need help Outlook VBA and Custom Forms 2
EaglePI Outlook 2010 need help with rules Using Outlook 0
B HELP! Using Outlook 4
Jeff Davis Help fix my Outlook 2013? Using Outlook 28
M Winmail. dat - HELP Using Outlook 2
Diane Poremsky Help! My Contacts are being updated! New Slipstick.com Articles 0
B VBA Help Email that will save as draft and send as attachment Outlook VBA and Custom Forms 3
J Can Anyone Help?? Outlook VBA and Custom Forms 1
C Newbie needs help with Outlook Macro Outlook VBA and Custom Forms 3
B Need Help - Willing to pay Outlook VBA and Custom Forms 10
D help with Item/Inspector close event Outlook VBA and Custom Forms 1
G Looking for help with our Organization Forms Library Outlook VBA and Custom Forms 1
J Need Help with Contacts VBA Outlook VBA and Custom Forms 1
Similar threads


















































Top