C# Outlook add-in get selected emails
I know it's a little late but this question ranks highly in search engines. Here is the solution I use to get selected emails in Outlook Interop:
internal static IEnumerable<MailItem> GetSelectedEmails()
{
foreach (MailItem email in new Microsoft.Office.Interop.Outlook.Application().ActiveExplorer().Selection)
{
yield return email;
}
}
That line retrieves the third selected message.
Selection[] is equivalent to Selection.Item() - Item function is marked as the indexed property accessor.
You cannot see the implementation - it is all in the Outlook Object Model.
All Outlook collections begin with 1, not 0. This is how it used to be in VB, so the Outlook Object Model uses the same convention.