0
votes

I am creating an outlook addin that provides a new ribbon button that will auto archive attachments and email according to date, sender, subject, attachment, name, etc. My question is, how can I access the sender/subject/attachment names/attachment file types in C# via the API, and how to tell whether or not there are attachments? The documentation is all over the place. Even a link to the correct docs or an example would do wonders. Lastly, how do I reference the current email (started via compose, read, etc.)? Will it be referenced automatically by my button being the ribbon since I set when it should show up in VS? Even if that's the case, my previous question of accessing the attributes still applies.

I did find this: https://msdn.microsoft.com/EN-US/library/office/ff861252.aspx

But I'm still not sure how to reference the current email to access the properties. As far as I can find it is undocumented. Most of the documentation is old, and if lucky it's VS2012 and Office 2010. Which is okay since 2013 is trying to move toward the cloud based apps and clients anyway, but anything older seems to use different ways to achieve things. Being able to access the properties of the current message and reference that current message whether it is being read or composed or a draft, would solve my problems.

Thanks in advance.

P.S. Microsoft's documentation is a mess for office addins :(

1

1 Answers

2
votes

I don't agree with you that MSDN doesn't provide enough information in this area. Take a look at the Outlook Solutions section in MSDN for more information about the Outlook object model and other dev things. Also I'd recommend reading any book on Outlook development. It will allow you to understand the Outlook object model better.

There are several ways to get a reference to the mail item currently shown in the inspector window.

  1. The ActiveInspector method of the Application class returns an instance of the Inspector class which provides the CurrentItem property which returns an Object representing the current item being displayed in the inspector (a mail item you are looking for).
  2. The Ribbon button's event handler provides the IRibbonControl instance which has the Context property. It represents the active window containing the Ribbon user interface that triggers a callback procedure (an inspector or explorer window). Then you can use the CurrentItem property of the Inspector class to get an instance of the Outlook item.