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
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
M Outlook 365 refuses to send email Using Outlook 1
B Search and Find Email by Folder Name Outlook VBA and Custom Forms 2
K Closing external IMAP email... Outlook 2013 Using Outlook 0
L Capture email addresses and create a comma separated list Outlook VBA and Custom Forms 5
C Email bomb processing Outlook VBA and Custom Forms 1
O What would be the recommended way to change an email address (family member)? Using Outlook 0
A Outlook 2016 Macro to Reply, ReplyAll, or Forward(but with composing new email) Outlook VBA and Custom Forms 0
L Checking Sender Email Address for trusted domain from list on intranet Outlook VBA and Custom Forms 4
J How do you disable address search box when typing @ in body of email? Using Outlook 0
S HTML Code Embedded in String Within Open Outlook Email Preventing Replace(Application.ActiveInspector.CurrentItem.HTMLBody From Working Outlook VBA and Custom Forms 4
Victor.Ayala Automated way to check the option "Show this folder as an email Address Book" Outlook VBA and Custom Forms 2
D Wrong email address in Outlook 2003 "From" tab in new outgoing emails Using Outlook 4
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

Similar threads

Top