R
Rune Jacobsen
I am building an application that stores information about activites related
to customers. It's using .Net 3.5 Sp1, C#, WPF, LINQ etc. One thing I want to
support is the ability to drag'n'drop a bunch of emails from Outlook and
extract the subject, sender, time and body from each mail, and store them as
an activity. From what I gather, this should be possible via the
Microsoft.Office.Interop.Outlook assembly. Whenever I get a drop operation on
my window that could be one or more emails dragged over, I want to query
Outlook like this;
var ol = new Microsoft.Office.Interop.Outlook.Application();
var sel = ol.ActiveExplorer().Selection;
However, it gives me an System.AccessViolationException when I try to do this.
The strange thing is that I can easily subscribe to the NewMailEx event (for
instance) and be notified when new mails arrive, this works without a
problem. So what do I need to do in order to have Outlook allow me to access
the current selection of mails in the ActiveExplorer() so that I can get at
my selected items?
I am on Windows Vista 2007 Sp1, Office 2007 Ultimate, and my assemblies are
signed if that matters.
to customers. It's using .Net 3.5 Sp1, C#, WPF, LINQ etc. One thing I want to
support is the ability to drag'n'drop a bunch of emails from Outlook and
extract the subject, sender, time and body from each mail, and store them as
an activity. From what I gather, this should be possible via the
Microsoft.Office.Interop.Outlook assembly. Whenever I get a drop operation on
my window that could be one or more emails dragged over, I want to query
Outlook like this;
var ol = new Microsoft.Office.Interop.Outlook.Application();
var sel = ol.ActiveExplorer().Selection;
However, it gives me an System.AccessViolationException when I try to do this.
The strange thing is that I can easily subscribe to the NewMailEx event (for
instance) and be notified when new mails arrive, this works without a
problem. So what do I need to do in order to have Outlook allow me to access
the current selection of mails in the ActiveExplorer() so that I can get at
my selected items?
I am on Windows Vista 2007 Sp1, Office 2007 Ultimate, and my assemblies are
signed if that matters.