VBA Macro or rule to automatically move e-mails sent/received to a specific contact/mail folder?

  • Thread starter Alastair Cameron
  • Start date

Alastair Cameron

I'm sure this question has been asked a million times, but here goes

I'd like to have e-mail messages that are received from, or sent to,
specific e-mail addresses AUTOMATICALLY moved from the Inbox (or Sent
Items) folder in to specific folders (one per contact) I have created.

I believe a VBA macro may be the best way of doing this - I have looked
at message rules but don't like the idea of having to define/maintain
hundreds and hundreds of rules which are the same but differ only for
e-mail address/destination folder.

The e-mail addresses are defined as Outlook contacts, and surprisingly
Outlook 2003 does not seem to offer any automatic way of saying "when
e-mail from this contact arrives or when e-mail is sent to this contact
move the message to this folder" or am I missing something obvious?

I'm an experienced VBA Excel/Word developer, and have done a little
Outlook VBA stuff, so VBA code won't scare me but would appreciate some
pointers. I couldn't quite work out how to designate the name of the
folder that I want the messages moves to for each person - could I
define a user-defined field for the contact and store the folder name

If anybody has any suggestions or can point me to any solutions then I
would be very grateful.



Michael Bauer

Hi Alastair,
I'm sure this question has been asked a million times, but here goes

Yes, roughly as often as there is the request: Please don´t post in more
than two groups at once .-)

For monitoring the Inbox you can use its Item´s ItemAdd event. Please
see the VBA help for a sample.

If the folder name is contact related then you maybe can derive it from
the ContactItem´s name? This would be helpful for an also automaticaly
new folder creation for new ContactItems.

But it´s possible to create an user-defined field, too. For that please
see ContactItem.UserProperties.Add.


I had the same problem, only I needed to be sorted by Subject in a
public folder. I ended up writing a Macro in Excel that referenced Outlook.
The hardest part is accessing the MAPI folders and differetn things. In your
outlook, hit Alt F-11 and bring up the VBA Editor. In the outlook session,
you can write your code and test it from there. If you want to run it in
Excel when your done, just put Outlook. In front of the MAPIFolder
declarations or other declarations specific to that class. And make srue in
Excel you are referencing the Outlook in Tools->Reference. Check this page
out below to see a good example of where to start.


If you need more help, I can help with that, I'm just stuck on automating it
now through SQL Server.

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