Drag Outlook application from Outlook to WPF datagrid

I saw this code Euler about dragging and dropping attachments ( http://www.codeproject.com/Articles/28209/Outlook-Drag-and-Drop-in-C ) from Outlook to Windows Form and it works fine in Windows Forms, but I I can not get it to work with WPF. I tried just changing System.windows.form.IDataObject to System.Windows.IDataObject, but it does not work (as I should have guessed).

I also just tried to get the contents of the e.Data FileContents file, but always get errors (which seems to apply to everyone when I check on the Internet).

Has anyone ever dragged an application from Outlook to WPF? I will completely lose.

Edit: I am not trying to get the file from Windows Explorer windows (but I know how to do it). This is really all that is connected with the attachment directly from Outlook, which does not work. I also fully understand that I could just transfer the file from Outlook to a temporary folder and then transfer it to my program, but I would like to avoid this, if possible, an extra step.

+4
source share
1 answer

so in the end I managed to find a link where someone did just that:

https://gist.github.com/MattyBoy4444/521547

For those who are wondering. Here is what I did for sure.

  • Create a new project in C # (my code is in VB) and add the code to it
  • Link to a new project in my main project so that it can use it.
  • "" , "FileGroupDescriptorW" , .

If obj.GetDataPresent("FileGroupDescriptorW") Then 'Outlook
    Dim oOutLookObj As New Helpers.OutlookDataObject(e.Data)
    Dim StrFiles() As String = oOutLookObj.GetData("FileGroupDescriptorW")
    Dim contentStream() As System.IO.MemoryStream = oOutLookObj.GetData("FileContents")
    ' Do intended work...
End if 

StrFiles, . .

+3

All Articles