Is anyone aware of a technique I could use to override someone opening an email attachment within an outlook add-in?
Essentially what I'm being asked to do, is for certain attachments, to change the behavior so instead of opening the attachment the user is redirected to a webpage.
I can hook into the attachment context menu with Application.AttachmentContextMenuDisplay
however that is not fired if the user simply double clicks on an email attachment.
Environment used is VS2010, c#, and outlook 2007/2010.
You should take a look at the ItemEvent
BeforeAttachmentRead
and BeforeAttachmentPreview
. See this related post for reference.
((Outlook.ItemEvents_10_Event)MailItem).BeforeAttachmentRead += new Outlook.ItemEvents_10_BeforeAttachmentReadEventHandler(ItemEvents_BeforeAttachmentRead);
((Outlook.ItemEvents_10_Event)MailItem).BeforeAttachmentPreview += new Outlook.ItemEvents_10_BeforeAttachmentPreviewEventHandler(ItemEvents_BeforeAttachmentPreview);