Security Manager does not supress Outlook message

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

Security Manager does not supress Outlook message
 
Anna Li




Posts: 2
Joined: 2016-04-13
Hello,
we just bought Security manager license for evaluation.
We hoped it would help us get rid of Outlook security message when users drag and drop emails from Outlook to our .NET Desktop app running on Citrix servers. However, message still appears. Here's my code, pls let me know if I didn't use your APIs in the right way.


public void ProcessEmailDragDrop(System.Windows.IDataObject dataObject)
		{

            // third party add-in allows to avoid Outlook Security Message
            AddinExpress.Outlook.SecurityManager securityManager = new AddinExpress.Outlook.SecurityManager();
		    try
		    {
		        securityManager.DisableOOMWarnings = true;
                
		        //Only allow emails to be Drag-Dropped.
		        if (dataObject != null && !dataObject.GetDataPresent(ApplicationConstants.DragDropFormats.GROUP_FORMAT))
		        {
		            this.SetStatusMessage(ApplicationConstants.StatusMessages.DRAG_DROP_NOT_CORRECT_FORMAT_MESSAGE);
		            return;
		        }
                 
		        Explorer oExplorer = _outlook.ActiveExplorer();
		        Microsoft.Office.Interop.Outlook.Selection oSelection = oExplorer.Selection;
		        Microsoft.Office.Interop.Outlook.Folder oFolder =
		            (Microsoft.Office.Interop.Outlook.Folder) oExplorer.CurrentFolder;

		        try
		        {		            
		            if (oSelection.Count > 1)
		            {
		                this.SetStatusMessage(ApplicationConstants.StatusMessages.CORRESPONDENCE_MORE_THAN_ONE_EMAIL_MESSAGE);
		            }
					           

		            object item = oSelection[1];

		            Microsoft.Office.Interop.Outlook.MailItem mi = item as Microsoft.Office.Interop.Outlook.MailItem;
						           
					// MAP mi object to my business object here....
		            

		            Marshal.ReleaseComObject(mi);
		            mi = null;
		            
		        }
		        catch (Exception ex)
		        {
		            ModalErrorDialog.ShowExceptionModal(ex, GlobalEnums.LogLevel.LOG_Error);
		        }
		        finally
		        {
		            //! Drag/drop in Outlook 2010 is broken, so here we do a folder switch to clear and then reset the active selection. REMOVE AFTER GOING TO 2015!!!
		            // Now clear the selection; do this by changing to another folder (Outbox, which should be empty), then back again
		            oExplorer.CurrentFolder =
		                _outlook.GetNamespace("MAPI")
		                    .GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderOutbox);
		            oExplorer.CurrentFolder = oFolder;

		            Marshal.ReleaseComObject(oSelection);
		            Marshal.ReleaseComObject(oExplorer);
		        }
		    }
		    finally
		    {
                // In any case please remember to turn on  
                // Outlook Security after your code,  
                // since now it is very easy to switch it off!
		        securityManager.DisableOOMWarnings = false;
		    }
		} 
Posted 13 Apr, 2016 07:37:14 Top
Andrei Smolin


Add-in Express team


Posts: 14140
Joined: 2006-05-11
Hello Anna,

Anna Li writes:
// MAP mi object to my business object here....


Would it be correct to assume that the issue occurs on this code line(s)?

Is this code run in a standalone application? If so, you must call securityManager.ConnectTo(_outlook) before using securityManager.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 13 Apr, 2016 08:29:07 Top
Anna Li




Posts: 2
Joined: 2016-04-13
That worked. Spasibo.
Posted 13 Apr, 2016 10:45:40 Top
Andrei Smolin


Add-in Express team


Posts: 14140
Joined: 2006-05-11
Thank you, Anna! )))

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 14 Apr, 2016 02:05:43 Top