Issue with file drag/drop to Outlook in Windows 10

  • Thread starter Thread starter kleinma
  • Start date Start date
K

kleinma

Guest
I have found an issue where a piece of code that always worked suddenly stopped after users of the software moved to Windows 10. The specific issue is that we can't drag/drop a file into an Outlook mail message, only on Windows 10. The same code works on previous versions of Windows. I created a repro of the issue. If you paste this code into a new WinForms project and you have Windows 10 you can see it in action. I can drag/drop to a folder/desktop in Windows. I can drag to applications like Chrome or Adobe Reader. It is JUST Office applications that no longer work in Windows 10.


For example, if you drag from this sample app to the desktop, and then from the desktop to Outlook, it works. You just can't drag directly from the WinForms app to an Outlook mailmessage. Oddly enough, if you attach a file to a new mail message manually so that the "attachments" bar appears in the mail message, you CAN drag/drop from this sample app to the "attachments" box, and it works. If there was a way to always show the attachments bar in an outlook mail message, that COULD be a viable workaround for now, but from my research you can't toggle this. It only appears when an attachment is present.


When I run the same code on Windows 7 and Outlook 2010, it works fine. I have been told by the users of the software that it also works as expected on Outlook 2013 on Windows 7. It appears to be a Windows 10 thing, or a Windows 10/Office 2013 combination. I don't have a Windows 10 with Office 2010 setup to test that scenario though.

I am out of ideas here.

Public Class Form1

Private sampleFile As String = Application.StartupPath & "\sample.txt"
Private DragDropLabel As New Label

Public Sub New()

' This call is required by the designer.
InitializeComponent()

' Add any initialization after the InitializeComponent() call.

DragDropLabel.Dock = DockStyle.Fill
DragDropLabel.BorderStyle = BorderStyle.FixedSingle
DragDropLabel.Text = "Drag From Here to target"
DragDropLabel.TextAlign = ContentAlignment.MiddleCenter
DragDropLabel.Font = New Font(Me.Font.Name, 14)
Me.Controls.Add(DragDropLabel)
AddHandler DragDropLabel.MouseDown, AddressOf Label_MouseDown
End Sub

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

'CREATE SAMPLE TEXT FILE IF IT DOES NOT EXIST
If Not IO.File.Exists(sampleFile) Then
My.Computer.FileSystem.WriteAllText(sampleFile, "HELLO WORLD", False)
End If

End Sub

Private Sub Label_MouseDown(sender As Object, e As MouseEventArgs)
If (e.Button And MouseButtons.Left) = MouseButtons.Left Then

Dim fileDataObject As New DataObject
fileDataObject.SetFileDropList(New Collections.Specialized.StringCollection() From {sampleFile})
DragDropLabel.DoDragDrop(fileDataObject, DragDropEffects.Copy)

End If
End Sub
End Class







Matt Kleinwaks - MSMVP MSDN Forums Moderator - www.zerosandtheone.com

Continue reading...
 
Back
Top