Johk Kara
11-05-2007, 01:46 PM
Hi,
I am working on a machine running Win Xp and Outlook 2003. Outlook has (2) two pop3 accounts setup i.e. email1@test.com and email2@test2.com and all email is saved in one pst. email1@test.com is set as the default account and as such executes a rule that forwards all incoming mail to an external account. What I would like is to have all mail forwarding to go through email2@test2.com and still have email1@test.com as my default account.
I have been doing some searching and came accross the code below, for forwarding I just don't have the knowhow to adjust it so as to make the forwarding procedure go through the secondary account.
////////
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 "johk@example.com"
' Send it
myForward.Send
End If
End If
End Sub
/////
I would greatly appreciate any help on solving the above problem. Thanking you in advance for your adive and co-operation.
Regards
Johk
I am working on a machine running Win Xp and Outlook 2003. Outlook has (2) two pop3 accounts setup i.e. email1@test.com and email2@test2.com and all email is saved in one pst. email1@test.com is set as the default account and as such executes a rule that forwards all incoming mail to an external account. What I would like is to have all mail forwarding to go through email2@test2.com and still have email1@test.com as my default account.
I have been doing some searching and came accross the code below, for forwarding I just don't have the knowhow to adjust it so as to make the forwarding procedure go through the secondary account.
////////
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 "johk@example.com"
' Send it
myForward.Send
End If
End If
End Sub
/////
I would greatly appreciate any help on solving the above problem. Thanking you in advance for your adive and co-operation.
Regards
Johk