Hello,
I copy-pasted a macro to automatically forward new email to an external address (rules are blocked), obviously it runs only when outlook is running:
Is there any way to program a macro to check for (and forward) messages that were received prior to outlook launch?
Thanks!
I copy-pasted a macro to automatically forward new email to an external address (rules are blocked), obviously it runs only when outlook is running:
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)
' 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 "(email address)"
' Send it
myForward.Send
End If
End Sub
However it doesn't forward new email that was received before launching outlook. ie if I launch outlook at 8am, email that was received at 7am appears in my inbox but is not forwarded, only messages that are received after 8am are forwarded.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)
' 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 "(email address)"
' Send it
myForward.Send
End If
End Sub
Is there any way to program a macro to check for (and forward) messages that were received prior to outlook launch?
Thanks!