[VSTO] Addin to prohibit to add attachments

  • Thread starter Thread starter Mercier
  • Start date Start date
M

Mercier

Hello,

I want to develop an Addin to Outlook which can prohibit to add an
attachment to a mail, so I have to intercept an event which occur when the
user clicks on the attach button.
I still want the attach button to be visible.
I want to show a popup and prevent the user to choose a file for attachment.
Do you know how I can do such a thing or where is the object representing
this button in the outlook component model ?
I develop with Visual Studio Tools For Office.

Thank you very much.
 
What version of Outlook?

If this is Outlook 2007 you can use the new BeforeAttachmentAdd event to
tell you when an attachment is being added to an item. That event has a
Cancel Boolean argument that if set to true cancels the adding of the
attachment.

Of course if you prohibit any attachments you would also be prohibiting any
pasting of images into the items, since those are embedded attachments.

An alternative is to repurpose the various controls that add attachments.
How you do that depends again on the Outlook version. For Outlook 2003 you'd
use the Inspector.CommandBars collection, for Outlook 2007 you'd use the
Ribbon controls.
 
I want to do that on all outlook versions, but now, I work on Outlook 2003

I had allready searched in the Inspector.CommandBars collection, but it
returns the command bars of Word which is used to write de mail, and the
button is an Outlook Button.
I had allready searched in the activeExplorer and in all the explorer and
inspector into the Application.Explorers and Application.Inspectors
collections and the button isn't present. (the same is true for all the
buttons of that command bar)
 
For an open item it's only Inspectors you have to be concerned with.

When WordMail is being used you won't be able to repurpose the original
buttons because they aren't exposed to you as you've found.
 
Back
Top