Am 4 Nov 2005 09:48:57 -0800 schrieb
(E-Mail Removed):
> If Time() < #7:00:00 AM# Or Time() > #5:00:00 PM# Then
Use the AND operator instead of OR.
--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
> here's a quick summary of what i'm trying to do. if an email arrives
> from a certain address after 5pm and before 7am it is automatically
> forwarded to another email. i found the following code on microsoft's
> site but i can't seem to modify it so that it'll do what i need.
> MailItem has something called SenderEmailAddress but i can't figure out
> how to use it. tia.
>
>
> =================================================================
>
> 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 7:00 A.M. and 5:00 P.M.
> If Time() < #7: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 Removed)"
>
> ' Send it
> myForward.Send
>
> End If
>
> End If
>
> End Sub