How to detect 'Forward As Attatchment' event in C# Outlook Add-in development.
I want to show message 'You can't forward this mail as attatchment' in message box.
Note that, This is not VSTO application.
There is no straight scenario or trivial way for handling such cases in Outlook. There are several ways to handle such scenario as possible workarounds.
The first possible solution is to handle the MailItem.Forward event which is fired when the user selects the Forward
action for an item, or when the Forward
method is called for the item, which is an instance of the parent object. In the event handler you may check for attached files, display a message box and cancel the action if required. To handle item-level events you may consider creating an inspector wrapper (or item-wrapper) where you could set up event handlers correctly, see Implement a wrapper for inspectors and track item-level events in each inspector for more information.
The second possible solution is to handle the ItemSend event of the Application
class in Outlook where you could handle all outgoing emails, not only forwarded.
The third solution is to repurpose the UI control which is responsible for the action in Outlook. So, you may replace the default action with your own or just prepend it with your custom logic. See Temporarily Repurpose Commands on the Office Fluent Ribbon for more information.