I want to get all selected emails in my Outlook 2010 add-in. I found this MSDN tutorial, but I am a beginner at C#, and I don't quite understand this line of code: Object selObject = this.Application.ActiveExplorer().Selection[3];
I believe Selection[]
is something like overridden operator, indexer in C#. But, is there any way to see implementation of it? If I go through the code, I only see interfaces but not implementations. So I don't know the structure of the Selection object. What is really behind the operator []
.
Also, why do the selected items begin at index 1 and not 0?
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;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With