Drag and Drop email

Add-in Express™ Support Service
That's what is more important than anything else

Drag and Drop email
Drag and Drop email into ADXOlForm 
Subscribe
Haseeb Mukhtar




Posts: 6
Joined: 2024-08-29
Hi

I have added ADXOlFormsManager in AddinModule and then added ADXOlFormsCollectionItem. For form selection item settings are:
Cached: OneInstanceForAllFolders
ExplorerItemTypes: Mail
ExplorerLayout: BottomNavigationPane
FormClassName: Forms.frmOpenMatters

The form is showing correctly and all fine.

I want to add functionality to drag email from inbox (or any other folder) and drop to this form to save email file in local drive.

I need to get the subjectline to use as file name and content steams to save file.

Tried several ways in DragDrop event but not working.

Tried e.Data.GetData("FileGroupDescriptor") to get stream. tried e.Data.GetData("FileContents") but nothing working. What is the best way to do it.


Using Outlook for Office365 and addinexpress v 10.2
Posted 10 Sep, 2024 13:54:37 Top
Andrei Smolin


Add-in Express team


Posts: 19011
Joined: 2006-05-11
Hello Haseeb,

Have a look at https://www.add-in-express.com/creating-addins-blog/outlook-task-pane-drag-drop/.

Regards from Poland (GMT+2),

Andrei Smolin
Add-in Express Team Leader
Posted 10 Sep, 2024 17:39:40 Top
Haseeb Mukhtar




Posts: 6
Joined: 2024-08-29
Hi Andrei,
Thanks for your replay.

This blog "Outlook, custom task pane and drag-drop problem" is suggesting the solution for issue with selectionChange and SelectionCount issue.

What I am looking for is how to get MailItem from IDataObject. Tried using e.Data.GetData("FileGroupDescriptor") and other ways but none was working to save .msg using IDataObject from DragEventArgs.

Currently found another way to get selected email from OutlookApp.ActiveExplorer().Selection in DragDrop event and save.

 Outlook.Selection selection = AddinModule.CurrentInstance.OutlookApp.ActiveExplorer().Selection;
 foreach (var sel in selection)
 {
     if(sel is Outlook.MailItem mailItem)
     {
         var subject = mailItem.Subject;
     }
 }



Now going to work on how to save from Outlook.MailItem.

Probably it would be great to add helder class to get MailItem or stream from IDataObject (DragEventArgs)

Thanks
Posted 10 Sep, 2024 19:09:39 Top
Andrei Smolin


Add-in Express team


Posts: 19011
Joined: 2006-05-11
Hello Haseeb,

Thank you for the suggestion.

Please note that your code fragment breaks two rules of handling COM objects: 1) do not chain COM calls and 2) do not use a foreach loop on COM collections, use a for loop instead. Check section Release all COM objects created in your code; see the PDF file in the folder {Add-in Express}\Docs on your development PC.

Regards from Poland (GMT+2),

Andrei Smolin
Add-in Express Team Leader
Posted 12 Sep, 2024 07:25:35 Top
Haseeb Mukhtar




Posts: 6
Joined: 2024-08-29
Hi Andrei,

Thank you, I will update the code accordingly :)
Posted 12 Sep, 2024 09:03:30 Top
Andrei Smolin


Add-in Express team


Posts: 19011
Joined: 2006-05-11
You are welcome!

Regards from Poland (GMT+2),

Andrei Smolin
Add-in Express Team Leader
Posted 12 Sep, 2024 17:00:50 Top