# Outlook VBA to move emails to folders (like rules)



## ADAMC (Jan 12, 2012)

Hi all firstly thanks for any replies  as always grately appreciated.

Scenario:
I maintain a group outlook exchange email account. For data protection every email sent out TO a client, a copy is sent to a single sub folder named 'flowlinks'.
There is a lot of traffic back and to often we need to search back through the flowlinks folder to find original correspondance but due to the sheer amount of emails it can be time consuming.

My idea:
Create a sub folder for each client and set up a rule to say "when the email hits 'flowlinks' see who the email was sent to and move it to the folder with the same client name.

Problem:
I have 33 clients Outlook says after 4 I have no more room to create any more rules!
This leads me to hopefully a VBA solution:

What I want my VBA to achieve:

When an email arrives in the flowlinks sub folder from person A,B,C,D,E,F,G,H,I,J,K,L only (Theres only 12 people) 
Look at the email address in the 'TO' field
If it contains @client1 move it to client 1 sub folder
if it contains @client2 move it to the client 2 sub folder....an so on.

Im no VBA expert but even if someone could give me a rough syntax im pretty sure I could figure it out.....any alternative solutions also very welcome!

Thank you!


----------



## JP2112 (Jan 23, 2012)

At the risk of self-aggrandizement, the code found here should be a good starting point: http://www.jpsoftwaretech.com/outlook-vba/stock-event-code/

You would need to modify (1) to point to your 'flowlinks' folder, and (3) would need to contain your business rules for 

figuring out who the email came from;
figuring out who the email is to;
determing the destination folder (and making sure it exists), and
moving the message to that folder.


----------



## ADAMC (Feb 2, 2012)

Thanks very much for your reply, gives me something to work with; appreciated!


----------

