I have inherited an office 2010 plugin for Outlook. It is supposed to be able to save the mails, attachments or both in a seperate database/file. It saves the mails incl attachments just nicely (aka both). If I choose only to save the attachments it still saves both (mail + attachments), that being – a nice msg file with attachments included (msg being outlook mail file format).
There is also an Office 2003/2007 version that can do this correctly, either saving the mail, the attachments or both pending on choice. I have been reviewing the code for a couple of days now and I haven’t been able to find the difference between what the 2003/7 is capable of and what 2010 is not capable of.
Can it be that the Outlook 2010 can’t save mails and attachments seperately from a code perspective?
Details:
Office 2003 plugin: Written in C#, .NET3.5, VS8
Office 2007 plugin: C#, .NET3.5, VS8
Office 2010 plugin: C#, .NET4, VS10
We have officially retired the 2003 version and is nolonger maintaining that. 2007 is being bugfixed when somebody reports anything. 2010 is the “new” black 😉
I may have found a key point
protected override void EnableAddAttachmentsToLegis()
{
// Adds a button on the right click context menu,
// when user clicks on an attachment:
_application.AttachmentContextMenuDisplay
+= new Outlook.ApplicationEvents_11_AttachmentContextMenuDisplayEventHandler
(Application_AttachmentContextMenuDisplay);
}
http://technet.microsoft.com/en-us/query/bb623145 – bummer, good question is now – what replaced it, or was it completely abolished.
Which has been replaced by 2007 – http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.applicationevents_11_event_members.aspx – which deprecated for 2010.
I have done something like this times ago when I was using Outlook. I’m going to outline my steps:
Subscribed to the new mail event:
The handler provides you with a list of all new mails using a comma separated string. I splitted and processed each of the ids:
The processMail function retrieves the mailitem and iterates ofer all attachments if there are attachments:
The processAttachment function’s core just saved the attachment using
The functions in my add in do a bit more ( e.g.creating a directory structure ), but the basic idea should have become obvious. Doing this for mail items outside the mail new event is probably following the same steps.