How to drag email from Outlook to a .NET application?

I am trying to figure out how to drag an email from Outlook 2010 into my .NET application. I have seen many articles, most of which were very complex. I thought it should not be so difficult ... but I could be wrong.

Any help would be greatly appreciated!

+7
c # outlook
source share
2 answers

A simpler solution is available here: Get body from Outlook email [DragnDrop]

Outlook.Application outlook = new Outlook.Application(); Outlook.Explorer oExplorer = outlook.ActiveExplorer(); Outlook.Selection oSelection = oExplorer.Selection; foreach (object item in oSelection) { Outlook.MailItem mi = (Outlook.MailItem)item; Console.WriteLine(mi.Body.ToString()); } 

Uses Microsoft.Office.Interop.Outlook.dll . (This is on NuGet with the same name)

+5
source share

The two answers above are good. However, there are a few things you need to know.

In the first answer, you can download a sample program and run it, and you will find that everything works fine while you run it on a 32-bit computer, otherwise you will have to recompile your program from "AnyCPU" to "X86". I spent most of today trying to figure out why the first two characters of the .msg file name (from the letters) that I was dragging were missing. As soon as I recompiled with "X86", everything began to work.

In the second answer, you will find that yes, you can use the code, and it is much simpler, however, if you need your application to run in a different version of Outlook (except the one you added to your links), this probably will not work . I used to use the same Office objects that were mentioned in the second answer, and I ran into problems all the time when someone wanted to use my program in a different version of Office (i.e. if I pulled out in Office version 14, and they wanted to use it in Office 2007).

0
source share

All Articles