title: VSTO Outlook 2007 Add-in Context Menu CommandBarButton click event
body: <p>I need to add a button to the context menu of the inbox.  I have this working fine.  What I need to figure out is in the implementation of the event handler how do I determine which item/items was clicked?</p>
  
  <pre>
  <code>
  private void AddIn_Startup(object sender, EventArgs e)
  {
     Application.ItemContextMenuDisplay += Application_ItemContextMenuDisplay;
  }
  
  private void Application_ItemContextMenuDisplay(CommandBar commandBar, Selection selection)
  {
     commandBar.Controls[1].BeginGroup = true; // add seperator before first menu
  
     var cmdButtonCopy = (CommandBarButton)commandBar.Controls.Add(MsoControlType.msoControlButton, 1, Missing.Value, 1, Missing.Value);
     cmdButtonCopy.Caption = "&Copy Message";
     cmdButtonCopy.Click += cmdButtonCopy_Click;
  }
  
  private void cmdButtonCopy_Click(CommandBarButton ctrl, ref bool canceldefault)
  {
       // no sender/event args to determine which item was clicked ...
  }
  </code>
  </pre>
  
  <p>In the cmdButtonCopy_Click event handler I need to copy the specific item that was right-clicked but I can't figure out how to tell which item was clicked.</p>