VBA Script to check incoming emails [with attachment e.g, .zip or .gz] for specific 'keywords' then move them to another folder. RRS feed

  • Question

  • Is there anyone who can help with this?
    Thursday, July 23, 2020 8:52 AM

All replies

  • You need to handle the NewMailEx event of the Applications class which is fired once for every received item that is processed by Microsoft Outlook. The item can be one of several different item types, for example, MailItem, MeetingItem, or SharingItem. The EntryIDsCollection string contains the Entry ID that corresponds to that item. 

    The NewMailEx event fires when a new message arrives in the Inbox and before client rule processing occurs. You can use the Entry ID returned in the EntryIDCollection array to call the NameSpace.GetItemFromID method and process the item. Use this method with caution to minimize the impact on Outlook performance. 

    The Outlook object model supports three main ways of customizing the message body:

     - The Body property returns or sets a string representing the clear-text body of the Outlook item.
     - The HTMLBody property of the MailItem class returns or sets a string representing the HTML body of the specified item. Setting the HTMLBody property will always update the Body property immediately. 
     - The Word object model can be used for dealing with message bodies.

    See Chapter 17: Working with Item Bodies for more information.

    Finally, to move items to another folder you need to use the Move method.

    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    Thursday, July 23, 2020 6:38 PM