Log in

View Full Version : ThisOutlookSession olInboxItems_ItemAdd Event



kdberg2
07-22-2015, 04:20 AM
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

skatonni
07-22-2015, 05:03 AM
There is a limit of 16 items. http://www.outlookcode.com/article.aspx?id=62