5

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?

default
  • 11,485
  • 9
  • 66
  • 102
UJ.
  • 337
  • 2
  • 4
  • 15
  • 6
    Have a look here, maybe it helps: http://www.eggheadcafe.com/software/aspnet/34867978/event-for-email-message-select.aspx. You shouldn't care about the mouse click, but about a selection change in the list of emails. – Daniel Hilgarth Mar 14 '11 at 12:04
  • Thanks Daniel, link you provided was helpful. – UJ. Mar 16 '11 at 05:03
  • 1
    Should this be marked as answered then? – Rob Feb 22 '12 at 13:47
  • 1
    @DanielHilgarth would have to create an answer out of his comment so that it could be marked as the answer – Jason Kleban Apr 13 '12 at 14:56

2 Answers2

0

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);
                }
            }
Community
  • 1
  • 1
negEntropy
  • 319
  • 1
  • 5
0
    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
            {

            }
        }
Sharique Ansari
  • 1,458
  • 1
  • 12
  • 22