View Single Post
  #6  
Old February 1st 07, 01:06 AM posted to microsoft.public.vb.general.discussion,microsoft.public.outlook.program_vba,comp.lang.basic.visual.misc
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Best way to start a program when specific email received?

You can prototype your code as a macro that runs automatically in the
Outlook VBA. It would be put in the ThisOutlookSession class.

Dim WithEvents colItems As Outlook Items

Private Sub Application_Startup()
Dim oNS As Outlook.NameSpace

Set oNS = Application.GetNameSpace("MAPI")
Set colItems = oNS.GetDefaultFolder(olFolderInbox)
End Sub

Then just select colItems in the left drop-down, ItemAdd in the right
drop-down and the prototype of the event handler will be added to the class.
The next time you start Outlook it will run for every new item (for 15 or
fewer items at a time). Make sure your macro security is set to allow the
macro to run.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Bill" wrote in message
...
On Wed, 31 Jan 2007 10:11:08 -0500, "Ken Slovak - [MVP - Outlook]"
wrote:

The best and most robust way is to use an Outlook COM addin, which can
handle the ItemAdd event in the Items collection of the Inbox.


Thank you.

I've done quite a bit of programming, but never used COM.

I will look into that. Do you have a suggestion I might be able to
use more quickly?

Thanks.


Ads