Consulting

Results 1 to 2 of 2

Thread: ThisOutlookSession olInboxItems_ItemAdd Event

  1. #1
    VBAX Newbie
    Joined
    Jul 2015
    Posts
    1
    Location

    ThisOutlookSession olInboxItems_ItemAdd Event

    Is olInboxItems_ItemAdd reentrant, or does arrival of another item in the Inbox while a previous one is still processing wait on completion of the first?

    Option Explicit
    '
    ' "ThisOutlookSession" class module
    '
    ' Pseudo code to describe reentrant question
    '
    
    
    Private WithEvents olInboxItems As Items
    
    
    Private Sub Application_Startup()
        Set olInboxItems = Session.GetDefaultFolder(olFolderInbox).Items
    End Sub
    
    
    Private Sub olInboxItems_ItemAdd(ByVal Item As Object)
    
    
        On Error Resume Next
     
        Dim olMailItem As MailItem
        Dim strAttachmentName As String
        '
        ' Only inspect mail items
        ' Ignore appointments, meetings, tasks, etc.
        '
        If TypeOf Item Is MailItem Then
            Set olMailItem = Item
    
    
            If olMailItem.Attachments.Count = 1 then
                ' do some stuff 
                ' call some Module1 subroutines that may take a minute or so to execute
                ' and also set the values of some Public variables
                '
                ' So what happens if we are executing here or in a Module1 sub and another email comes in?
            end if   
     
        Set Item = Nothing
        Set olMailItem = Nothing
    End Sub

  2. #2
    VBAX Mentor skatonni's Avatar
    Joined
    Jun 2006
    Posts
    347
    Location
    There is a limit of 16 items. http://www.outlookcode.com/article.aspx?id=62
    To debug, mouse-click anywhere in the code. Press F8 repeatedly to step through the code. http://www.cpearson.com/excel/DebuggingVBA.aspx

    If your problem has been solved in your thread, mark the thread "Solved" by going to the "Thread Tools" dropdown at the top of the thread. You might also consider rating the thread by going to the "Rate Thread" dropdown.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •