none
Hiding file attachments on messages

    Question

  • I've run into a little snag on an outlook add-in I am working on.  When a user opens a file attachment in 2007 or 2010 if they dbl click it from the explorer view (without first dbl clicking the message itself to open details of the message) then outlook puts it in read only view.  I don't want it to do that on file attachments in any messages that were sent from our add-in.  I see there is a beforeattachmentpreview event but the problem I have is that our add-in needs to run in 2003/2007/2010 and this event was only made available in outlook 2007.  My references to the interop assemblies are 2003 as that's the lowest version I'm supporting to i have to reference this. This means that I have no way (that i know of) to handle events that are only available in 2007/2010.  i.e. even if i use late binding, I cannot figure out how to handle the events in a late binding call.  Is there a way to do that--i..e if this is a user in 2003 I wouldn't need to handle the event anyhow as outlook won't put the file attachment in read only mode so i could check the version and if it's 12 or higher then i could do late binding and override the beforeattachmentopen or preview event.

     The next option I thought up (not sure if it will work) was to try to tell outlook to hide the file attachments on any messages that are sent from our add in (we can inspect each message in user's inbox when they click on it --by handling outlook explorer.selectionchanges event--and looking at some custom properties to see if the email was sent from last user with our tool or not). If it was sent with our tool and has a  file attachment, I could try to hide the icon for file attachment if this user is running outlook 2007/2010.  But I cannot get this to work.  I tried property name "http://schemas.microsoft.com/mapi/id/{00062008-0000-0000-C000-000000000046}/8514000B" and using propertyaccessor (late binding call to use this method only if we detect user is running outlook 2007 or higher as propertyAccessor not available in 2003), but when coding this from the seletionchange event of explorer it is not hiding the icon for attachment when setting the value to true or false.  i'm not sure if it's because it is difficult to make this change to the email when you are handling selection change event (since you need to call the save method on the message and that recursively calls selectionchange event again).  But i don't know where else to code it.  The only other thing i thought up was to handle the event when new emails arrive and update the message there instead of when they click on it but i couldn't get that to work either.  I also know there is another way to hide attachment at the attachment level rather than at the mail item level, but i think that is only available if the user is running outlook 2007 or higher so i don't think i can code anything for when the user is trying to send the outgoing message from our add-in (as i won't be able to make the att read only if they are on 2003).  

    This seems like it should be easy to either override the opening of files and if they try to open it in preview mode tell them they can't, or just hide the file attachments and make them use our interface to open the files rather than doing it from outlook message.  But i'm not sure how to either hide the file attachment or handle the event that they open the file, given what is said above about coding for 2003/2007/2010.  Any help you can give is appreciated on a direction to take. thanks !

    Thursday, December 27, 2012 5:44 PM

All replies