PC Review


Reply
Thread Tools Rate Thread

automatically forward from a specific email address

 
 
teamakg@gmail.com
Guest
Posts: n/a
 
      4th Nov 2005
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

 
Reply With Quote
 
 
 
 
Michael Bauer
Guest
Posts: n/a
 
      23rd Nov 2005
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

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Forward a copy to another email address automatically Jan Chase Microsoft Outlook Discussion 1 1st Nov 2009 07:07 PM
automatically forward a message from 1 specific address Skieruk Microsoft Outlook Discussion 1 15th Jan 2008 07:02 PM
How do create a macro to forward email to a specific address? =?Utf-8?B?QXJsb1NtdXJm?= Microsoft Outlook Discussion 4 7th Jan 2007 05:51 AM
Automatically email spreadsheet through Outlook to a specific email address Todd Microsoft Excel Misc 2 27th Aug 2004 11:21 PM
automatically forward email to another email address Brian Microsoft Outlook Discussion 0 28th Jul 2004 02:52 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:32 PM.