Set off VBA macro on email receipt then that macro accesses the emailcontent

  • Thread starter gimme_this_gimme_that
  • Start date
G

gimme_this_gimme_that

Is there a mechanism that allows developers to set off a VBA macro
upon the receipt of every email?

(Sort of like the out-of-office mechanism but evoking a VBA macro
instead of a new email message.)

Also does someone have an example where this is set up and the VBA
macro
accesses the email content of the message that was received?

I'm using Outlook 2003.

Thanks.
 
K

Ken Slovak - [MVP - Outlook]

You can use the ItemAdd event handler for the Items collection of the Inbox
for that.

Search for "zaphtml" at www.outlookcode.com for an example of an ItemAdd
handler that converts all HTML emails into plain text emails.
 
G

gimme_this_gimme_that

Hi Ken,

The tip you provided lead me on a journey where I ended up installing
Collaboration Data Objects. (Microsoft CDO 1.2.1 Library).

This URL was helpful: http://j-integra.intrinsyc.com/support/kb/article.aspx?id=113792
..

I followed the instructions and forturnately I was able to install
from the network without a CD.

Now....

1. Where is the recommended place to put the code for
Application_Startup() and olInboxItems_ItemAdd() ?

Microsoft Office Outlook Objects ->ThisOutlookSession-> (General
Module)

Or anyplace, such as:

Modules -> Module1

2. When I log out of this account - will the AddItem code turn off?

Thanks.
 
K

Ken Slovak - [MVP - Outlook]

The code goes in the ThisOutlookSession class. The code is running
in-process with Outlook, so if Outlook is closed the code stops.
 

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