Macro for moving mails to folders according to specific criteria

Jul 2, 2014
Reaction score
Me and my colleagues are facing quite an unusual problem. We daily receive several messages with specific format. We need to sort this messages according to the body text, to be precise according to text in the 2nd and 4th line.

Here is an example:[/FONT]
[FONT=&quot]K QS100P 02JUL02JUL 0030000 00073H 0740BTS P[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]This is a message from our partner and we need to move it automatically from INBOX folder (or any other folder) to the folder S14 (line 2) and subfolder PRG (line 4)[/FONT]

Currently we have a file tree and we sort these messages manually, which is obviously a pain.

I found several tips how to create a macro which moves messages to personal folders but I can't implement the If condition (if there is specific text on line 2 move it to specific folder).

Could you please help me to create such macro?

Thanks a lot in advance![/FONT]
Jun 6, 2014
Reaction score
Well then, you have to search for 2 VBA codes.
1. To Read Email text.
2. To move to a PST.

I believe you code to do the second one. Check this article on reading a email subject or body. It might be of some help to you.
Article with VBA To read Email Details.

Now integrate both code and put a If condition after you get the Email text.
Hope this helps.

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question