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
D Wrong email address in Outlook 2003 "From" tab in new outgoing emails Using Outlook 2
D Forwarding email based on the attachment file type and specific text found on the attachment file name Outlook VBA and Custom Forms 1
F Forward incoming email with 4 embedded images in the body without original sender Outlook VBA and Custom Forms 22
W Macro to Filter Based on Latest Email Outlook VBA and Custom Forms 6
D Create advanced search (email) via VBA with LONG QUERY (>1024 char) Outlook VBA and Custom Forms 2
C Outlook 2007 Removing then adding account restores junk email processing Using Outlook 0
G Place jpg in body of email Outlook VBA and Custom Forms 1
F Wishlist Outlook suddenly began synchronizing deleted items every time I delete a single email. Using Outlook 2
N Save Selected Email Message as .msg File Outlook VBA and Custom Forms 12
HarvMan Toggle between calendar and email in Outlook 365 Using Outlook 12
F Email being marked as Spam by Gmail and not being visible in Outlook Using Outlook 5
G Email time stamp Using Outlook 2
G Schedule recurring email and attachments display Outlook VBA and Custom Forms 3
G Save and Rename Outlook Email Attachments Outlook VBA and Custom Forms 0
B Need to Copy an email to a subfolder Outlook VBA and Custom Forms 2
M How to setup outlook after importing old account information - Entering email account info creates with "(1)" after the account! Using Outlook 1
K Multiple Rules on Single Email Using Outlook 2
F VBA to move email from Non Default folder to Sub folders as per details given in excel file Outlook VBA and Custom Forms 11
e_a_g_l_e_p_i Outlook 2010 How to set default email address for website links Using Outlook 3
O Same email address, same person, names in so many ways Using Outlook 4
D Create new email from the received Email Body with attachment Outlook VBA and Custom Forms 10
D Outlook launch email showing new unread email in reading pane Using Outlook 11
B Zoom automatically next email item (VBA) Outlook VBA and Custom Forms 2
K Outlook adds space to rows in HTML email signatures viewed on mobile Using Outlook 1
M HTML email signature in Outlook Using Outlook 3
M Respond to Outlook Email Outlook VBA and Custom Forms 0
U Outlook locking up when replying to Email Using Outlook 7
S Email Generated from another program and then edited sends original email. Using Outlook 2
G Forward email body to other mail list directly from Exchange server Exchange Server Administration 1
S Unable to extract text from an Outlook email message Using Outlook 2
T Original email text not shown when replying or forwarding the email. Using Outlook 6

Similar threads

Top