Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming Forms / January 2004

Tip: Looking for answers? Try searching our database.

Code that fires whenever an email arrives...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
J S - 15 Jan 2004 07:25 GMT
I have some vba code in the ThisOutlookSession Module that causes some code
to run whenever an email arrives in the inbox.

Normally, this works fine except when I open up the VBA enviroment and do
some editing. Then the olInboxItems_ItemAdd event stop firing until I
restart outlook. Does anybody know why this is occuring and if I can stop
this behavior?

       -J

Private WithEvents olInboxItems As Items
------------------------------------------------------------------
Private Sub Application_Startup()

 Dim objNS As NameSpace
 Set objNS = Application.GetNamespace("MAPI")
 ' instantiate objects declared WithEvents
 Set olInboxItems = objNS.GetDefaultFolder(olFolderInbox).Items
 Set objNS = Nothing
End Sub
------------------------------------------------------------------
Private Sub olInboxItems_ItemAdd(ByVal Item As Object)
   'Code that will run when a new email item arrives in the inbox
End Sub
Ken Slovak - [MVP - Outlook] - 16 Jan 2004 16:06 GMT
That is expected behavior if you are editing the VBA project code.
After you are done just place the cursor in the Application_Startup
event handler and press F5 to execute it again and your ItemAdd
handler should start working again.

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

> I have some vba code in the ThisOutlookSession Module that causes some code
> to run whenever an email arrives in the inbox.
[quoted text clipped - 20 lines]
>     'Code that will run when a new email item arrives in the inbox
> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.