4

If I select an Outlook message from my Inbox and copy it to the clipboard I can paste it as an *.msg file to the Desktop.

Now I want to implement the same feature to my application.

The Clipboard object contains the following elements:

RenPrivateSourceFolder
RenPrivateMessages
RenPrivateItem
FileGroupDescriptor
FileGroupDescriptorW
FileDrop
FileNameW
FileName
FileContents
Object Descriptor
System.String
UnicodeText
Text

FileGroupDescriptor contains a MemoryStream with the filename (Subject.msg) but I don't know how to create a copy from the outlook message from the Clipboard data, since none of the elements seem to contain the message itself.

Any Suggestions?

SliverNinja - MSFT
  • 31,051
  • 11
  • 110
  • 173
Jürgen Steinblock
  • 30,746
  • 24
  • 119
  • 189

2 Answers2

7

Here is an example: Outlook Drag and Drop in C#. The article works with drag and drop but it should be similar if not identical for working with clipboard.

Giorgi
  • 30,270
  • 13
  • 89
  • 125
  • 1
    That totally works, thanks mate, I searched the whole internet for an example but missed that page because Clipboard is not in the article. – Jürgen Steinblock Jan 17 '11 at 13:52
-2

Not sure if this will work, but you have to do something like:

if (Clipboard.ContainsText(System.Windows.Forms.TextDataFormat.Text))
{
    IDataObject data = Clipboard.GetDataObject();
    Outlook.Application oApp = new Outlook.Application();
    Outlook.MailItem oMsg = (Outlook.MailItem)data.GetData(DataFormats.Text, true);
}
SliverNinja - MSFT
  • 31,051
  • 11
  • 110
  • 173
iTSrAVIE
  • 846
  • 3
  • 12
  • 26