Context menu issue with Outlook 2016

Add-in Express™ Support Service
That's what is more important than anything else

Context menu issue with Outlook 2016
Gregg Linnell

Posts: 3
Joined: 2012-11-19
We have a context menu item added to the context menu for attachments. It is used for popping up our own save form, to save the attachment(s) into our own document management system.

Below is the code that we use, which works fine for versions of Outlook up to 2013, however it fails when run against Outlook 2016:

Outlook.AttachmentSelection test = (control.Context as Outlook.AttachmentSelection);
var attSelection = (control.Context as Outlook.AttachmentSelection).OfType<Outlook.Attachment>();
List<Outlook.Attachment> listAttachments = new List<Outlook.Attachment>();

foreach (Outlook.Attachment att in attSelection)
{ listAttachments.Add(att); }

SaveToNorwel(new List<Outlook.MailItem>(), listAttachments, new List<Outlook.ReportItem>());[COLOR=red]

The line begin var attSelection is what fails. The error generated is:

Value cannot be null.
Parameter name:source

So basically "control.Context as Outlook.AttachmentSelection" is equating to null.

I did put a message in and control.Context itself is not null.

What should the above code be to work on all versions of Outlook, or what additional code should be added that just works with Outlook 2016.

Posted 06 Mar, 2017 10:38:35 Top
Gregg Linnell

Posts: 3
Joined: 2012-11-19
It's OK, I have sorted the issue now.
Posted 06 Mar, 2017 11:01:07 Top