C
Cody
I am using Outlook 2003 and want to do the following:
Email received between 6 pm to 9 am is forwarded to (e-mail address removed)
Email received between Friday @ 6pm to Monday @ 9 am is forwarded to
(e-mail address removed)
Email received between 9am to 6pm is forwarded to (e-mail address removed)
I have looked on the web and found the following code on the MS website; but
unfortunately I am not sure where I am suppose to modify it. If you can
give me any guidance, I would appreciate it.
********
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)
' If it's currently not between 9:00 A.M. and 5:00 P.M.
If Time() < #9:00:00 AM# Or Time() > #5:00:00 PM# Then
' 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
' Forward the item just received
Set myForward = Item.Forward
' Address the message
myForward.Recipients.Add "(e-mail address removed)"
' Send it
myForward.Send
End If
End If
End Sub
********
Thanks...Cody
Email received between 6 pm to 9 am is forwarded to (e-mail address removed)
Email received between Friday @ 6pm to Monday @ 9 am is forwarded to
(e-mail address removed)
Email received between 9am to 6pm is forwarded to (e-mail address removed)
I have looked on the web and found the following code on the MS website; but
unfortunately I am not sure where I am suppose to modify it. If you can
give me any guidance, I would appreciate it.
********
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)
' If it's currently not between 9:00 A.M. and 5:00 P.M.
If Time() < #9:00:00 AM# Or Time() > #5:00:00 PM# Then
' 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
' Forward the item just received
Set myForward = Item.Forward
' Address the message
myForward.Recipients.Add "(e-mail address removed)"
' Send it
myForward.Send
End If
End If
End Sub
********
Thanks...Cody