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
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.
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.
Similar threads
Thread starter Title Forum Replies Date
Nufc1980 Outlook "Please treat this as private label" auto added to some emails - Help. Using Outlook 4
A How to stop user form from disapearing once mail window is closed? Outlook VBA and Custom Forms 0
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
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
T How to set Default FONT for Email composing ? Using Outlook 0
H Finding text in open email Outlook VBA and Custom Forms 12
T Why do Outlook Desktop 2021 tasks from my wife's email show up in my task pane? Using Outlook 2
A Opening a link from an email automatically Outlook VBA and Custom Forms 0
D Outlook 2021 New email reminder Using accounts in Outlook 1
Rupert Dragwater How do I remove an email ending with Using Outlook 4
M A plug in (or method) to keep email message formatting after it expires Using Outlook 1
L VBA to Triage Incoming Email Outlook VBA and Custom Forms 0
R Legacy Outlook on Mac Email Cache Using Outlook 0
P Email address auto-completes work fine on laptop, but no longer on desktop Using Outlook 3
S Create Outlook Task from Template and append Body with Email Body Outlook VBA and Custom Forms 4
H Copying email address(es) in body of email and pasting in To field Outlook VBA and Custom Forms 1
A Search folder and move the email Outlook VBA and Custom Forms 0
P VBA to add email address to Outlook 365 rule Outlook VBA and Custom Forms 0
farrissf Outlook 2016 Optimizing Email Searches in Outlook 2016: Seeking Insights on Quick Search vs Advanced Search Features Using Outlook 0
D Delete selected text in outgoing email body Outlook VBA and Custom Forms 0
F Graphics in email / Mac recipient garbled Using Outlook 0
D Outlook VBA forward the selected email to the original sender’s email ID (including the email used in TO, CC Field) from the email chain Outlook VBA and Custom Forms 2
Witzker Outlook 2019 Macro to seach in all contact Folders for marked Email Adress Outlook VBA and Custom Forms 1
E Outlook 365 Save Selected Email Message as .msg File - oMail.Delete not working when SEARCH Outlook VBA and Custom Forms 0
S Email Macros to go to a SHARED Outlook mailbox Draft folder...NOT my personal Outlook Draft folder Using Outlook 2
R Outlook 365 VBA AUTO SEND WITH DELAY FOR EACH EMAIL Outlook VBA and Custom Forms 0
G Print email attachments when hit subfolder Outlook VBA and Custom Forms 1
C Spam Email? Using Outlook 2
G Automatically delete email when a condition is met Outlook VBA and Custom Forms 1
E Save Selected Email Message as .msg File - digitally sign email doesn't works Outlook VBA and Custom Forms 1
S Email was migrated from GoDaddy to Microsoft exchange. We lost IMAP ability Exchange Server Administration 1
R Outlook 365 How to integrate a third-party app with Outlook to track email and sms? Using Outlook 2
S Paperclip icon shows without attachment in email under Sent folder Using Outlook 0
B Outlook 2019 Automatically move email after assigning category Using Outlook 4

Similar threads