Search code examples
c#outlookvstoadd-in

Modifying current email item visually


I'd like to ask if there is any possibility to modify the currently selected item's sender visually only. I just want to visualize text next to the sender's email.

I'm applying image to visualize what I am trying to achieve enter image description here

What I have tried so far is using the ActiveInspector and modifying the current item's Sender.Address value.

    public static void test(MailItem item)
    {
        var currItem = item.GetInspector.CurrentItem;

        if(currItem == Microsoft.Office.Interop.Outlook.OlObjectClass.olMail)
        {
            currItem.Sender.Address += "test";
        }
    }

Any ideas? I've seen that the currentItem is System.__ComObject.


Solution

  • There is no trivial way for customizing the sender's information without changing the underlying properties of Outlook items.

    You may try using Windows API functions for subclassing Outlook windows and injecting your own form on top of built-in ones. See SetWindowsHookEx for more information, it installs an application-defined hook procedure into a hook chain. You would install a hook procedure to monitor the system for certain types of events. These events are associated either with a specific thread or with all threads in the same desktop as the calling thread.

    Also you may consider using the replacement-all form region layout. A replacement form region is a page that replaces the default page of a standard form, and a replace-all form region replaces all pages in a standard Outlook form.

    As the last resort, you may consider using Add-in Express layouts where you can hide the sender's pane and show your own.