PDA

View Full Version : Outlook VBA question



dcox
08-20-2009, 10:45 AM
Ok I am really new to using VBA for Outlook so I could use help and guidance. I got a little frustrated with the Rules Wizard not really doing what I wanted.

Let me explain the setup and then what I am looking at doing

We have a bunch of different distribution groups, one for each client company we deal with, emails sent to and from those clients are all suppose to be sent to the distribution group for that client so everyone who deals with them is kept informed of what is going on. Unfortunately this means a lot of emails which may not directly pertain to me are in my Inbox. Of course until the emails are read who knows if it really pertains you you or not. Now we also have our mobile smart phones synced to the exchange server so we always get our emails even when out of the office. This can be very important to our work of course.

Here is what I am wanting to do, though I have no clue about the syntax.
New mail all comes into the inbox, hangs around there until I am able to read it. Once it is read then it gets moved to a folder for that distribution group. In a perfect world I would like to actually have the code look for the folder named the same as the distribution group, if it doesn't exist create a new folder, and then take the read message and move it to that folder. Eventually I would actually like a sub folder which stores all them messages sent to the group but not sent to me specificly.

Here is kind of how I expect the logic of the code to run

-------

If message = unread then goto end

check if the email was to a distro group

If not then goto end

check if there is folder with name = distro group

if not create folder

"Here I figure would be the check for a sub folder and if not a creation of it"

"if email was set to me specificly then we would do a move to the folder for my stuff here"

move email to folder named distro group.

--------

For the most part the rules will do some of this it is simply the initial check for if the email is read or not, also the creation of the new folders but I can always do that manually, just have to code in the error that the directory doesn't exist so i can go and create it if I forgot to. Of course now comes the problem are for me, how. The logic and troubleshooting I am good at but the initial coding I am perpetually confused. Any help would be appreciated.

JP2112
09-01-2009, 06:00 AM
See http://www.codeforexcelandoutlook.com/outlook-vba/stock-event-code/ for the basic code and customize for your needs.