VirtualFileDataObject implementation does not work for Outlook 365

149 Views Asked by At

I have followed the example found here. It implements the IDataObject interface to create a "virtual file" dataobject. The implementation works perfectly well when d/d the virtual files from a WPF application to the file system and outlook emails (files are attached to the email). I updated recently to Outlook 365 and suddenly it stopped working for it, debugging the code shows that the process actually executes the function that download the files but these are never shown as attachments in the email.

Does anybody know if the way the d/d is processed from outlook changed in 365? Please, any hint.

The code for the VirtualFileDataObject class can be found here

This is the code that set the FileDescriptor's list with the function that retrieves the virtual files:

VirtualFileDataObject.FileDescriptor[] files = new VirtualFileDataObject.FileDescriptor[myItems.Count];
        for (int i = 0; i < myItems.Count; i++)
        {
            var name = myItems[i].ItemName;
            files.SetValue(
            new VirtualFileDataObject.FileDescriptor
            {
                Name = name,
                StreamContents = stream =>
                {
                    try
                    {
                        using (var webClient = new WebClient())
                        {
                            var data = webClient.DownloadData(myItems[i].Url);
                            stream.Write(data, 0, data.Length);
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show($"File '{name}' could not be copied.\n{ex.Message}", "Drag and Drop", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
            }, i);
        }
        virtualFileDataObject.SetData(files);
1

There are 1 best solutions below

0
On BEST ANSWER

This issue was present only in Outlook 365 version 2004. After updating Office 365 to the following versions the issue disappeared completely.