5
votes

I am creating a addin for Office 2007 using C#. This addin is responsible to display email header information in a new pane whenever a user clicks on email from email list within Inbox pane. Now I am not sure how do I get mouse click event on the Inbox pane when a user selected an email and read that emails header information. Any helpful pointer?

2
Have a look here, maybe it helps: eggheadcafe.com/software/aspnet/34867978/…. You shouldn't care about the mouse click, but about a selection change in the list of emails. - Daniel Hilgarth
Thanks Daniel, link you provided was helpful. - UJ.
Should this be marked as answered then? - Rob
@DanielHilgarth would have to create an answer out of his comment so that it could be marked as the answer - Jason Kleban

2 Answers

0
votes

You can use the Microsoft V11.0 outlook object library (add the reference) and then query a MAPI mailbox:

http://geekswithblogs.net/TimH/archive/2006/05/26/79720.aspx or http://support.microsoft.com/kb/310258

Some requirements for accessing exchange inboxes with MAPI or POP3: C# MAPI to read exchange server inbox

Now, to get which inbox message has been selected, you could use:

Outlook.Explorer explorer = null;
explorer = outlookObj.ActiveExplorer();
            if (explorer.Selection.Count > 0)
            {
                var sel = explorer.Selection[1];
                if (sel is Microsoft.Office.Interop.Outlook.MailItem)
                {
                    var item = sel as MSOutlook.MailItem;
                    MessageBox.Show("Selected letter: "+item.Body);
                }
            }
0
votes
    private void ThisAddIn_Startup(object sender, System.EventArgs e)
    {

       this.Application.Inspectors.NewInspector += new Microsoft.Office.Interop.Outlook.InspectorsEvents_NewInspectorEventHandler(Inspectors_NewInspector);          
    }
 void Inspectors_NewInspector(Microsoft.Office.Interop.Outlook.Inspector Inspector)
        {
            try
            {
                Outlook.MailItem tmpMailItem = (Outlook.MailItem)Inspector.CurrentItem;
                if (tmpMailItem != null)
                {
                    if (Inspector.CurrentItem is Outlook.MailItem)
                    {
                        tmpMailItem = (Outlook.MailItem)Inspector.CurrentItem;
                        string to=   tmpMailItem.To;
                        string body = tmpMailItem.Body;
                    }
                }
             }
            catch
            {

            }
        }