#1
|
|||
|
|||
Auto Forward Emails - Specific Time Periods Only
I want to auto forward by rule email messages after hours. Is it possible to create a rule that would forward emails with a specific criteria during a specific set of hours? I got this VB code from someone, but I get an error message saying bad syntex when it gets to the place I have put in bold and underlined. Any thoughts on what I can do?
Private WithEvents objInboxItems As Items Private Sub Application_Startup() Dim objNS As NameSpace Set objNS = Application.GetNamespace("MAPI") ' instantiate Items collections for folders we want to monitor Set objInboxItems = objNS.GetDefaultFolder(olFolderInbox).Items Set objNS = Nothing End Sub Private Sub Application_Quit() ' disassociate global objects declared WithEvents Set objInboxItems = Nothing End Sub Private Sub objInboxItems_ItemAdd(ByVal Item As Object) Dim olItems As Items, _ olItem As Object, _ olMailItem As MailItem, _ olAttachmentItem As Attachment, _ bolTimeMatch As Boolean Set olItems = objInboxItems.Restrict("[Unread] = True") For Each olItem In olItems If olItem.Class = olMail Then Set olMailItem = olItem 'Change the times on the next line to those you want to use bolTimeMatch = (Time >= #6:00:00 PM#) And (Time <= #8:30:00 AM#) If bolTimeMatch Then Dim objMail As Outlook.MailItem Set objItem = olMailItem Set objMail = objItem.Forward 'PUT THE EXTERNAL EMAIL ADDRESS YOU WANT TO USE ON THE NEXT LINE objMail.To = "myemail.com" objMail.Send Set objItem = Nothing Set objMail = Nothing End If End If Next End Sub Function IsNothing(Obj) If TypeName(Obj) = "Nothing" Then IsNothing = True Else IsNothing = False End If End Function 'END CODE |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Sent emails all have same date/time?? | Confused | Outlook | 3 | 01-07-2011 07:52 AM |
Outlook 2007 - Notifications if emails are unread after a specific amount of time? | Robb | Outlook | 0 | 12-10-2010 11:18 AM |
Code to auto-forward weekend messages | Whang | Outlook | 0 | 06-16-2010 02:18 PM |
Auto-Forward Read Reply | timcar1 | Outlook | 0 | 10-13-2009 09:33 PM |
Auto forward return receipt to Requestor | sarav@msoutlook | Outlook | 0 | 12-09-2008 06:34 AM |