Outlook 2k: running vba when new mail arrives

B

Brian Schwartz

Hi all,

I'm using Outlook 2000 and need to run some VBA code when messages meeting
certain criteria arrive. I've tried using the Rules Wizard, but I can't find
an option to run a macro/script on the messages. I also noticed that the
ThisOutlookSession object includes an event for NewMail, but I have no idea
how to get started using it, since it includes no parameters and I'm not
familiar with the Outlook object model.

I have been programming in VB for some time, but Outlook is all new terrain
for me. I appreciate any pointers on how I might accomplish this goal.

Some additional details on what I need to do with the new messages: If it
has a certain subject line and the body contains a certain word, then I need
to:
- generate a unique, 20-character code (already have this)
- add a new record to a database with the code (know how to do this)
- get the new record's ID value (know how to do this)
- reply to the message and include the code (no idea how to do this)

Thanks!
Brian
 
S

Sue Mosher [MVP-Outlook]

Since you're using Outlook 2000, the "run a script" rule technique is not available to you. NewMail also is all but useless for processing new incoming messages. What you need to use instead is MAPIFolder.Items.ItemAdd. See http://www.outlookcode.com/d/code/zaphtml.htm and http://www.outlookcode.com/d/code/quarexe.htm for examples.

Each MailItem has a Reply method.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 

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

Top