Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Overriding Outlook's Default Sending function

Im developing a solution for Outlook with VSTO, VS 2010 and Outlook 2010.

I want to override default functionality of Outlook's sending behavior.

Here is the requirement.

When user clicks on Send button, i have to check whether it is an SMS - "IPM.Note.Mobile.SMS". If it is an SMS then i have to give my custom implementation for sending. If it is not an SMS then default sending behavior.

For custom sending part I have to use my own web service and handle it.

What i want from you is a method/way to override default sending function in Outlook 2010.

I have read few articles on MSDN, inspector wrappers and enforcing custom business rules, but i didn't get what i want. And i want a pure C# solution not a third party dll like redemption. I tried to be specific as much as i can, i expect the same :)

Please help me :D Thanks,

Regards - Sam

like image 504
Sam Avatar asked Dec 05 '25 10:12

Sam


2 Answers

You need to handle the Microsoft.Office.Interop.Outlook.Send event (ItemEvents_10_SendEventHandler). You can see the reference here. A rough example is provided below. You can get the message class from the inspector and the active inspector from the application reference.

((Outlook.ItemEvents_10_Event)inspector.CurrentItem).Send += new Outlook.ItemEvents_10_SendEventHandler(Inspector_Send);

void Inspector_Send(ref bool Cancel)
        {
            if (IPM.Note.Mobile.SMS) 
            {
               // custom implementation
            }
            else
              Cancel = true; // don't send the message out 
        }
like image 149
SliverNinja - MSFT Avatar answered Dec 08 '25 11:12

SliverNinja - MSFT


Here you have a different solution. Just include this line in your Add-in_StartUp:

Application.ItemSend += new Outlook.ApplicationEvents_11_ItemSendEventHandler(Application_ItemSend);  

And of course, the implementation of the event handler:

    void Application_ItemSend(object Item, ref bool Cancel)
    {
        MessageBox.Show("Yihha!!");
        Cancel = true;
    }

This will intercept any message you send.

like image 41
Joe Almore Avatar answered Dec 08 '25 10:12

Joe Almore



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!