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 |
|
Andrei Smolin
Add-in Express team
Posts: 19011
Joined: 2006-05-11
|
|
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 |
|
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 |
|
Haseeb Mukhtar
Posts: 6
Joined: 2024-08-29
|
Hi Andrei,
Thank you, I will update the code accordingly :) |
|
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 |
|