How to save an Outlook message from the clipboard to a file?

If I select an Outlook message from the Inbox and copy it to the clipboard, I can paste it into the * .msg file on the desktop.

Now I want to implement the same function for 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 file name (Subject.msg), but I do not know how to create a copy from an Outlook message from Clipboard data, since none of the elements seem to contain the message itself.

Any suggestions?

+4
source share
2 answers

Here is an example: Migrating Outlook to C # . An article works with drag and drop, but it should be similar if not identical for working with the clipboard.

+6
source

Not sure if this will work, but you should 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); } 
0
source

Source: https://habr.com/ru/post/1335824/


All Articles