none
When My Addin Runs And Accesses The Current Email At Load Time RRS feed

  • Question



  •     When my addin runs and accesses the current email a dialog opens up on top of my addin form and asks for permission to access email. I don't want this dialog to show. How do I stop this dialog from displaying?   

               

     

    Sunday, April 22, 2018 8:57 PM

All replies

  • What dialog? What does it say? What is the relevant snippet of your code that causes the prompt?

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Sunday, April 22, 2018 9:49 PM
  • Monday, April 23, 2018 12:32 AM

  •         private void ShowCurrentEmail()
            {

                try
                {



                    Microsoft.Office.Interop.Outlook._Application oApp = new Microsoft.Office.Interop.Outlook.Application();
                    if (oApp.ActiveExplorer().Selection.Count > 0)
                    {
                        Object selObject = oApp.ActiveExplorer().Selection[1];

                        if (selObject is Microsoft.Office.Interop.Outlook.MailItem)
                        {

                            Microsoft.Office.Interop.Outlook.MailItem mailItem = (selObject as Microsoft.Office.Interop.Outlook.MailItem);
                            String htmlBody = mailItem.HTMLBody;
                            txtDescription.Text = mailItem.Body;
                            txtSubject.Text = mailItem.Subject;
                        

                        }
                    }


                }
                catch(System.Exception Ex)
                {


                   throw Ex;


                }



            }

    Monday, April 23, 2018 12:33 AM
  • The security prompt is shown because you are using non-secure instance of the Outlook.Application object that you explicitly create. In an Outlok addin, use the Outlook.Application object passed to your addin.

    Is that a VSTO addin?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Monday, April 23, 2018 3:03 AM
  • Hello mike11111111233,

    I would suggest try to change the Programmatic Access Security setting in Outlook to get rid of the security message.  

    Go to File->Options->Trust Center->Trust Center Settings->Programmatic Access to change the setting.

    Or you could try to install an antivirus program and keeping it updated regularly might prevent this security warning from appearing again.

    Please check below document for more information.

    I get warnings about a program accessing email address information or sending email on my behalf

    Best Regards,

    Terry


    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, April 23, 2018 3:25 AM
  • @Terry Xu - MSFT
     - these settings will not work with Exchange. Outlook COM addins MUST use the secure instance of the Outlook.Application object passed to the addin on startup (available from Globals.ThisAddIn.Application in VSTO addins).

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Monday, April 23, 2018 3:36 AM
  •    Fairly certain it is a VSTO. I don't recall what option I choose in Visual Studio. The other is a web addin and I don't think I choose that.


    Monday, April 23, 2018 4:45 AM
  • yes, do use Globals.ThisAddIn.Application instead of "new Outlook.Application".


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Monday, April 23, 2018 5:19 AM
  • Mike,

    You need to use the Application object provided by the VSTO runtime instead of creating a new one:

    Microsoft.Office.Interop.Outlook._Application oApp = new Microsoft.Office.Interop.Outlook.Application();

    So, instead you should use the following statements:

    if (Globals.ThisAddIn.Application.ActiveExplorer().Selection.Count > 0)
                     {
                         Object selObject = Globals.ThisAddIn.Application..ActiveExplorer().Selection[1];
    
                         if (selObject is Microsoft.Office.Interop.Outlook.MailItem)
                         {
    
                             Microsoft.Office.Interop.Outlook.MailItem mailItem = (selObject as Microsoft.Office.Interop.Outlook.MailItem);
                             String htmlBody = mailItem.HTMLBody;
                             txtDescription.Text = mailItem.Body;
                             txtSubject.Text = mailItem.Subject;
                         
    
                         }
                     }
    

    At the same time I'd recommend breaking the chain of property and method calls. You must declare each property or method call on a separate line of code. So, you will be able to release them ASAP.


    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    Monday, April 23, 2018 8:25 AM
  •     Thanks Dimitry. Do you no Angular JS. I need someone to help out with my CRM project equity based. Would you be interested or know someone who is? It is a monster of an app about 95% complete

    Tuesday, April 24, 2018 1:39 AM
  •    Thanks Eugene

    Tuesday, April 24, 2018 1:40 AM
  • Hi mike,

    Has your current issue related with this dialog resolved? 

    If you have, I would suggest you mark the helpful reply as answer to close this thread.

    For Angular JS, you could post your issue on StackOverflow with tagging angularjs.

    Best Regards,

    Tao Zhou


    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, April 24, 2018 5:03 AM