Outlook 2007 - Visual Basic COM Add-In - ItemSend Event Priority

Lizzyosully
Lizzyosully used Ask the Experts™
on
Hi there,

I have written a simple COM add-in for Outlook 2007 in Visual Basic 6 to handle the ItemSend event. The idea is that when a user tries to send an email to internal recipients with an attachment greater than a pre-defined size, they will be prevented from doing so (by cancelling the sending and displaying a message box explaining why).

Everything is working as expected. The ItemSend routine is defined in the COM add-in and the events are captured using:

Private WithEvents objOLApp As Outlook.Application

Private Sub objOLApp_ItemSend(ByVal Item As Object, Cancel As Boolean)
     .........
     .........
End Sub

However, we are also running another custom add-in called "File Email to Job" in the office, written by a external company, which also seems to capture events from ItemSend. As a consequence, my add-in does not appear when an email is sent. The File to Job add-in appears instead.

My question is, is there a way for my add-in to gain priority when receiving ItemSend events or is it not possible to have these two add-ins running simultaneously?

Any help is very much appreciated.

Thanks  
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2010

Commented:
Hi, Lizzyosully.

I don't see where you are ever instantiating objOLApp.  Did you omit that from your example or is it in fact not happening?  If the latter, then that's the problem.  The event can't fire if objOLApp is never set.

Author

Commented:
Hi BlueDevilFan and thanks for your reply.

The object is being instantiated, here it is:

Private Sub AddinInstance_OnConnection(ByVal Application As Object, _
            ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, _
            ByVal AddInInst As Object, custom() As Variant)

   Set objOLApp = Application

End Sub

Like I mentioned, when the File to Job Add-in is not installed, my add-in works perfectly. However when File to Job is present, it seems to steal all the ItemSend events from my add-in. Do you understand what I mean?
Commented:
Hi BlueDevilFan,

you can check the attachement earlier before it is going to be sent -
m_olMailItem.AttachmentAdd  - > is an event triggered by adding attachements
where you can calculate the total size of the actual attachements and interfere when neccessary !

Try that one.
mekanoo

Author

Commented:
@mekanoo

Thanks, that is indeed a solution to my particular problem. However, I would still like to know if there is some sort of priority when it comes to events. I presume that events are handled by some sort of message queue so I'd be surprised if there wasn't some sort of event priority...

Author

Commented:
Not an exact solution but close enough

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial