0

Windows 7, Outlook 2010 Exchange.

I have an autoforward macro for incoming email that works flawlessly in forwarding all incoming email items to an external account I need for consolidation.

The only issue is every time I cold boot and START Outlook, the items that appear after the usual "Updating this folder..." in the ticker do NOT autoforward. From that point forward the macro starts working perfectly again.

It is located in the ThisOutlookSession.

In previous Outlook versions, a rule that ran a similar macro always fired upon startup.

Thanks for any help.

Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
    Dim varEntryIDs
    Dim objItem
    Dim myItem As MailItem
    Dim i As Integer
    varEntryIDs = Split(EntryIDCollection, ",")
    For i = 0 To UBound(varEntryIDs)
        Set objItem = Application.Session.GetItemFromID(varEntryIDs(i))

        If TypeOf objItem Is MailItem Then                     

            Set myItem = objItem.Forward
            myItem.Recipients.Add "bcc.hwb@gmail.com"

            myItem.DeleteAfterSubmit = True                    
            myItem.Send
            Set myItem = Nothing
        Else
            Debug.Print "Skipping " & TypeName(objItem)
            Set myItem = Nothing
        End If
    Next
End Sub
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
parodytx
  • 75
  • 1
  • 13

1 Answers1

0

Try to set up a rule which calls a macro sub instead of handling the NewMailEx event.

If you are running Exchange in non-Cached mode the event will only fire as long as Outlook is running when a new e-mail arrives. If you close and re-open Outlook, all the e-mails that were in the queue waiting to be delivered will appear in Outlook but the event will not fire. This is a well-known issue in Outlook.

You can read about all possible ways for handling incoming emails in the Outlook NewMail event unleashed: the challenge (NewMail, NewMailEx, ItemAdd) article.

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
  • Thanks for the informative explanation. Supposedly scripts were disabled by the company but I just created a "Hello World" macro passing the (myMail as Mailitem) argument in a new module and it shows up as an eligible script. I'll modify the code and see if I can get it to fly. Thanks again. – parodytx Feb 17 '15 at 15:41