Treat once an email with the ItemAdd event in a shared mailbox

Not open for further replies.


Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
I need your opinion on my current project.

I have a a shared mailbox, and 2 or more users. Each user has the program.

When a new Email is added in the Inbox Folder of this shared mailbox, i want to Print it just once.

No problem for printing it.

s my test for whether only the first that starts the treatment is good ?

Dim WithEvents colInboxPartageeItems As Items

Private Sub Application_Startup()
    Dim NS As Outlook.NameSpace
    Set NS = Application.GetNamespace("MAPI")
        Set colInboxPartageeItems = NS.Stores("Sin-constr.gsn").GetDefaultFolder(olFolderInbox).Items
End Sub
Private Sub colInboxPartageeItems_ItemAdd(ByVal Item As Object)

    If InStr(1, Item.Subject, "Test", vbTextCompare) Then
        If Item.FlagIcon = 0 Then

            Item.FlagIcon = olGreenFlagIcon
            On Error Resume Next
            '    : Number : -2147221239 : Long : ThisOutlookSession.colInboxPartageeItems_ItemAdd
            If Err.Number = -2147221239 Then
                Exit Sub
                Call go_Process_item(Item)
            End If

        End If
    End If
End Sub

Sub go_Process_item(Item)
    msgbox_uf.Show vbModeless
    msgbox_uf.TextBox1.MultiLine = True
    msgbox_uf.TextBox1 = Item & vbTab & Date & vbTab & Time & vbCrLf & msgbox_uf.TextBox1
End Sub

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
The IF should take of it - but Outlook 2010 doesn't use the colored flags. Use Categories or the completed flag instead. (if the flag or category doesn't stick, you'll need to too.)

But... if more than one computer receives the message at the same time, both will print it. if all 3 are never running at the same time, then it won't be a problem.


Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
potentially , multiple computers can receive mail almost the same time , I took the test !
But the first that saves, causes an error -2147221239 in the others, if the IF does not lead to the exit.

I will test it with Category.
Not open for further replies.
Thread starter Similar threads Forum Replies Date
DoctorJellybean Windows Security Credentials appears once a day Using Outlook 2
P Automatically Categorize Meetings once they are accepted Outlook VBA and Custom Forms 5
S How can I delete all copies of a given companies logo graphic from all my emails at once? Using Outlook 3
M possible to search Outlook for multiple email addresses at once? Using Outlook 1
M Can't open same msg file more than once at the same time in Outlook 2010 Using Outlook 7
V Cannot search multiple calendars at once Using Outlook 2
P Changing all email signatures (font, color) at once in outlook 2007 Using Outlook 2
anoble1 Can you create a rule once an email moves to the Vault Inbox to another place? Using Outlook 0
G Outlook Forms Blank once sent. Using Outlook 1
W Forward Meeting once Accepted Using Outlook 10
K Need to get OOO messages more than once for the same email box Using Outlook 2
M Outlook 2010 Rules Wizard Enter Multiple Items at once? Using Outlook 0
P Time Off Request - not posting to public folder once approved Using Outlook 0
S Outlook 2010 is not deleting mail from my server once downloaded Using Outlook 2
C Updating many contacts at once? BCM (Business Contact Manager) 3
D Outlook 2010 error - you are attempting to attach too many files at once Using Outlook 11
J calendar: populate multiple appointment subject fields at once Using Outlook 4
Z Outlook 2010 will not open - scanpst.exe. worked once now get to 'Loading Profile' and stays there (win 7) Using Outlook 1
B Outlook won't reopen once I close it down Using Outlook 3
S Outlook 2007, opens once....but will not reopen Using Outlook 1
B Outlook will only send and recieve once each time I turn it on Using Outlook 1
G Outlook 2007 once closed will not reopen must use task manger and end process Using Outlook 2
A Is it possible to send all emails from my drafts folder at once? Using Outlook 1
K emails downloaded to outlook and off of main server once downloaded. Using Outlook 1
P Once opened, cannot read attachment Using Outlook 2
F Outlook 2003 stops working once reminder pops up Using Outlook 11
J OWA freezing after login, must hit F5 at least once to make interactable Using Outlook 3
S Re: Outlook 2007 won't re-open once closed Using Outlook 1
D Outlook 2010 downloads emails more than once but outlook 2003 and Blackberry work correctly Using Outlook 2
C Outlook 2010 - Once I send an email message it will will sit in the Outbox for several hours before 'magically' be sent and then appear in t Using Outlook 1
M Sending an email invite to a scheduled reoccurring series of meetings at once even though certain occurrences in the series have been modified. Using Outlook 1
W Cannot launch Outlook 2007 properly; once launched, the menu items do not work properly. Using Outlook 1
T what to do to fix outlook 2010 once corrupted by dbx files? Using Outlook 9
B Emails stay present on my desktop once I send Using Outlook 1
B How do I delete all emails in an inbox, all at once, without deleting the inbox itself? Using Outlook 2
M Cannot restart Outlook 2010 once closed unless I logout/login again Using Outlook 2
R I am trying to see if outlook 2003 contacts - phone numbers format can be changed all at once. Using Outlook 2
R Stop Out of Office replying more than once Using Outlook 1
0 not able to open Outlook 2007 .msg files more then once Using Outlook 1
L Run code once form is sent Outlook VBA and Custom Forms 2
R Loop Attachment (once again) Outlook VBA and Custom Forms 6
J Emails stay in Outbox forever once addin is loaded Outlook VBA and Custom Forms 3
J Autoreply email recieved from specific sender after deleting some text from body. Using Outlook 0
M Outlook 2013 reminder email by using Outlook vba Outlook VBA and Custom Forms 2
D Sending email from Office 365 alias in Outlook Using Outlook 4
S Macro or plug-in to see if specific person was included in this email Outlook VBA and Custom Forms 3
S Body text of Email from invite date/time Outlook VBA and Custom Forms 8
R Outlook 2010 How do you export 2 email Accounts' 2010 Inbox Files to new computer (2019)? Using Outlook 1
R Auto display of new email does not work on non-default account Outlook VBA and Custom Forms 0
J Automatically forward email and apply template Outlook VBA and Custom Forms 0
Similar threads