VBA to move outlook email from inbox to other folders RRS feed

  • Question

  • Hello,

    Outlook rules are not working properly. Hence I want to use VBA for Outlook rules as it runs more efficiently.
    I have a Group email ID (IFC_Vendor_Master) in which we receive plenty of queries on our products.
    we have created 10 sub folders below Outlook default Inbox
    Outlook folder names are:-

    The above mentioned Folder names will be always available in the Outlook subject.
    I need a VBA code so that the email received in Inbox should automatically get saved in respective folders based on the subject. (the same was fixed in outlook rules but is not working properly).

    Could anyone provide me the complete code?


    Thursday, December 5, 2013 1:27 PM


  • Hello Amarsingh879,

    >> Outlook rules are not working properly.

    Could you publish the rule on the forum? It looks like you need to correct the rule in some way (not to develop a macro).

    Anyway, to get the job done you need to use the NewMailEx event of the Applications class. In the event handler you can get the incoming e-mail using the EntryID passed as a parameter (see the NameSpace.GetItemFromID method for details). Then you can check out the Subject property of the MailIItem class if any of the keywords presents in the string. Finally, based on the previous step you need to call the Move method of the MailItem class for moving the just received e-mail to a folder (or just leave it as is).

    Also the ItemAdd event of the Items class (use the Items collection of the Inbox folder) can be used as an alternative to the NewMailEx event.

    >> Could anyone provide me the complete code?

    As you may see the source code will not contain a single line or two. That is why I would recommend contacting professional developers/freelancers instead.

    Thursday, December 5, 2013 8:29 PM