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

Status
Not open for further replies.

oliv-

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
Hi,
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 ?

Code:
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
            Item.Save
            If Err.Number = -2147221239 Then
                Exit Sub
            Else
                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 item.save 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.
 

oliv-

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.
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
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
Witzker Outlook 2019 Macro to send an Email Template from User Defined Contact Form Outlook VBA and Custom Forms 0
Witzker Outlook 2019 Edit contact from email does not open the user defined contactform Using Outlook 3
V Macro to mark email with a Category Outlook VBA and Custom Forms 4
R Roadrunner Email Settings | Contact Roadrunner Customer Support Outlook VBA and Custom Forms 1
D Gmail mail is being delivered to a different email inbox in Outlook App 2021 Using Outlook 2
Albert McCann Outlook 2021 Outlook Display of HTML Email from two senders is glitchy Using Outlook 0
A How Do I Setup My Optonline.Net Email Account? Outlook VBA and Custom Forms 1
H Preventing the 'email address fetch from Exchange' crashing email reading code Exchange Server Administration 0
D multiple email accounts - why do I have to choose the "from" account address?? Using Outlook 2
Wotme create email only data file Using Outlook 1
F Outlook 2016 Email with attachments not being received Using Outlook 3
J Outlook 2019 Regex email addresses from body Outlook VBA and Custom Forms 6
D Prompt to prefix subject line whenever sending an email Outlook VBA and Custom Forms 3
J Quick steps delete original email and move reply/sent email to folder Using Outlook 2
C Wishlist Extract or scan new email addresses from out of office replies. Leads from OOO replies Using Outlook 1
T External email warning banner Outlook VBA and Custom Forms 0
A Links in email getting error message about group policy Using Outlook 4
richardwing Auto forward email that is moves into a specific outlook folder Outlook VBA and Custom Forms 5
J Recommendations for Outlook Duplicate Email Remover Using Outlook 6
Geldner Tweak Junk Email Reporting tool to default to particular email on send? Using Outlook 3
S Outlook 365 Can I change the possible range of highlighting colours when writing an Outlook email? Using Outlook 1
V Can one change the formatting of email title blocks? Using Outlook 0
P default font when sending email from browser Using Outlook 1
D VBA Macro to Print and Save email to network location Outlook VBA and Custom Forms 1
B IMAP server rejects sent email - cannot deliver messages Using Outlook 2
TedSch Small vba to kill political email Outlook VBA and Custom Forms 3
X Open Hyperlinks in an Outlook Email Message (Help with Diane's solution) Outlook VBA and Custom Forms 3
e_a_g_l_e_p_i Email notifications changed with Outlook 2021 Using Outlook 8
glnz How to retrieve or redo Verizon.net email password without affecting Outlook connection? Using Outlook 1
Z Copy specific email body text Outlook VBA and Custom Forms 0
D ISOmacro to extract active mail senders name and email, CC, Subject line, and filename of attachments and import them into premade excel spread sheet Outlook VBA and Custom Forms 2

Similar threads

Top