none
Drag & Drop files from 32bit winforms application to 64bit Outlook RRS feed

  • Question

  • Hi,

    dragging files from a 32-bit windows forms application to Outlook 64-bit (16.0.4573.1001) does not work. To reproduce, create a new email message, and then drag a file from the following windows forms application:

            private void Form1_MouseMove(object sender, MouseEventArgs e)
            {
                if (e.Button == MouseButtons.Left)
                {
                    string path = Path.Combine(Application.StartupPath, "Test.txt");

                    var files = new List<string>();
                    files.Add(path);

                    DoDragDrop(new DataObject(DataFormats.FileDrop, files.ToArray()), DragDropEffects.Copy);
                }
            }

    Be sure to set the platform to x86 and use a 64-bit version of Outlook.

    When dropping the file onto the new outlook email message, nothing happens. It starts to work as soon as the attachments box becomes visible, e.g. after adding any attachment using Outlook UI, but only if you drop the file on the attachments box.

    If you use 32-bit version of outlook, everything works as expected: Create a new email message, and drop the file from the application anywhere, e.g. on the email's body.

    Dragging from the 32-bit application to 64-bit windows explorer also works as expected.

    Thanks in advance.


    • Edited by devbcai Wednesday, August 23, 2017 7:09 AM
    Wednesday, August 23, 2017 7:07 AM

All replies

  • Hello,

    I could reproduce the issue. When setting platform to x86 or AnyCPU, it does not work for Outlook 64bit.

    It works when using x64 platform, I suggest you x64 platform for Office 64 bit.

    I also test VSTO add-in. I try to add a task pane and a winform. They both work for any platform. So I would suggest you create VSTO add-ins if you want to target any platform and do drag and drop for Outlook.

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, August 24, 2017 3:04 AM
    Moderator
  • Hello Celeste,

    thank you for having a look into that. Unfortunately, at this time, x64 platform is not an option for the source application, as it uses some x86 in-process components which are not available for x64 platform.

    I've also found that the following application seems to work:

    http://dlaa.me/blog/post/9917797

    Essentially, it uses dataformats CFSTR_FILEDESCRIPTORW and CFSTR_FILECONTENTS and a custom impementation of IDataObject, which is something I want to avoid in favor of stability and maintainability.

    Would you classify the problem as a bug in Outlook or Windows or .NET-Framework which might be fixed eventually?

    • Edited by devbcai Thursday, August 24, 2017 7:13 AM
    Thursday, August 24, 2017 7:10 AM
  • Hello,

    Thanks for sharing the information. 

    >>Would you classify the problem as a bug in Outlook or Windows or .NET-Framework which might be fixed eventually?

    For this issue, I'm trying to involve some senior engineers and it will take some time. Your patience will be greatly appreciated.

    Sorry for any inconvenience and have a nice day! 

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, August 25, 2017 8:29 AM
    Moderator
  • Hi devbcai,

    Thanks for your feedback.

    I made a test with your description, and I could reproduce your issue.

    For a work around on x64 Outlook, I would suggest you try to add the attachments by Outlook Object Model.

    Here is a simple code:

                if (e.Button == MouseButtons.Left)
                {
                    string path = Path.Combine(Application.StartupPath, "Test.txt");
    
                    var files = new List<string>();
                    files.Add(path);
                    //Drag and Drop behavior
                    DoDragDrop(new DataObject(DataFormats.FileDrop, files.ToArray()), DragDropEffects.Copy);
                    //Add the attachment by Outlook Automation
                    Microsoft.Office.Interop.Outlook.Application outlookApp =Marshal.GetActiveObject("Outlook.Application") as Microsoft.Office.Interop.Outlook.Application;
                    Microsoft.Office.Interop.Outlook.MailItem ins = outlookApp.ActiveInspector().CurrentItem;
                    foreach (var filePath in files)
                    {
                        ins.Attachments.Add(filePath);
                    }
                }

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Tuesday, August 29, 2017 7:19 AM
  • Hello,

    Microsoft confirms that it is a known issue on the Windows layer and being tracked now. Sorry for any inconvenience.

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, November 6, 2017 3:21 AM
    Moderator