Outlook GetSelectNamesDialog() Error: Operation aborted (Exception from HRESULT: 0x80004004 (E_ABORT))
-
martes, 31 de julio de 2012 18:55
Hi,
I have used the code exactly from msdn to open the Select Names Dialog to get all members of a distribution list. In Outlook 2010, on a test server, it works perfect, but not on Outlook 2007 in my work environment. I have the reference to Outlook Object Library 12.0 added to the project. It is a COMException, and I normally try/catch it, but the Select Names Dialog just doesn't show up either way. The exception is thrown at the Outlook.SelectNamesDialog snd = olApp.Session.GetSelectNamesDialog(); line. From searching, this is a security issue? But it isn't even getting to the point where it is grabbing the DL or members. I could understand if it is due to grabbing the members of a DL, but it doesn't get to that point. I do not have complete administrative rights to the Exchange server, but I may be able to adjust some things with permission. Is this a Exchange setup issue, Outlook issue, or am I missing something?
Thanks,
SethP.S. This is a WinForms application, not an add-in.
Todas las respuestas
-
miércoles, 01 de agosto de 2012 6:50when do you call this function? show us your code (starting from line where you instantiate application class of outlook)
-
miércoles, 01 de agosto de 2012 13:35
Outlook.Application olApp = new Outlook.Application(); Outlook.SelectNamesDialog snd = olApp.Session.GetSelectNamesDialog(); Outlook.AddressLists addrLists = olApp.Session.AddressLists; foreach (Outlook.AddressList addrList in addrLists) { if (addrList.Name == "All Groups") { snd.InitialAddressList = addrList; break; } } snd.NumberOfRecipientSelectors = Outlook.OlRecipientSelectors.olShowTo; snd.ToLabel = "D/L"; snd.ShowOnlyInitialAddressList = true; snd.AllowMultipleSelection = false; snd.Display(); if (snd.Recipients.Count > 0) { Outlook.AddressEntry addrEntry = snd.Recipients[1].AddressEntry; if (addrEntry.AddressEntryUserType == Outlook.OlAddressEntryUserType. olExchangeDistributionListAddressEntry) { Outlook.ExchangeDistributionList exchDL = addrEntry.GetExchangeDistributionList(); Outlook.AddressEntries addrEntries = exchDL.GetExchangeDistributionListMembers(); if (addrEntries != null) foreach (Outlook.AddressEntry exchDLMember in addrEntries) { Console.WriteLine(exchDLMember.Name); } } }
Thank you -
miércoles, 01 de agosto de 2012 16:35ModeradorSee if this works, you aren't logging into the Outlook session.Outlook.Application olApp = new Outlook.Application();
Outlook.NameSpace olNS = olApp.GetNameSpace("MAPI");olNS.Logon("", "", false, false);Outlook.SelectNamesDialog snd = olNS.GetSelectNamesDialog();
--
Ken Slovak
[MVP-Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007"Seth Jensen" <=?utf-8?B?U2V0aCBKZW5zZW4=?=> wrote in message news:d3672eb9-d5b4-421f-b0f5-53450df614c0...Outlook.Application olApp = new Outlook.Application(); Outlook.SelectNamesDialog snd = olApp.Session.GetSelectNamesDialog(); Outlook.AddressLists addrLists = olApp.Session.AddressLists; foreach (Outlook.AddressList addrList in addrLists) { if (addrList.Name == "All Groups") { snd.InitialAddressList = addrList; break; } } snd.NumberOfRecipientSelectors = Outlook.OlRecipientSelectors.olShowTo; snd.ToLabel = "D/L"; snd.ShowOnlyInitialAddressList = true; snd.AllowMultipleSelection = false; snd.Display(); if (snd.Recipients.Count > 0) { Outlook.AddressEntry addrEntry = snd.Recipients[1].AddressEntry; if (addrEntry.AddressEntryUserType == Outlook.OlAddressEntryUserType. olExchangeDistributionListAddressEntry) { Outlook.ExchangeDistributionList exchDL = addrEntry.GetExchangeDistributionList(); Outlook.AddressEntries addrEntries = exchDL.GetExchangeDistributionListMembers(); if (addrEntries != null) foreach (Outlook.AddressEntry exchDLMember in addrEntries) { Console.WriteLine(exchDLMember.Name); } } }
Thank you
Ken Slovak MVP - Outlook -
miércoles, 01 de agosto de 2012 20:40Thanks for the suggestion, but I am still getting the same error.
-
jueves, 02 de agosto de 2012 9:06
are you connected to exchange in outlook where this happens? what is status of your connection? (Application.Session.ExchangeConnectionMode). Do you have the same problem when you start outlook normally as a user and in VBA editor inside outlook you run code to show SelectNamesDialog?
-
jueves, 02 de agosto de 2012 15:31I am connected, verified by the ExchangeConnectionMode field. I do not know what you mean by "Do you have the same problem when you start outlook normally as a user." I can start Outlook normally, do you mean in code? I am trying to run VBA code, but I am unfamiliar with VBA so it is going very far as of yet.
-
jueves, 02 de agosto de 2012 18:08I can successfully open the Select Names Dialog with VBA. I guess I could rewrite my application in VB, but I feel VB is... sloppy.
- Editado Seth Jensen jueves, 02 de agosto de 2012 18:12
-
jueves, 02 de agosto de 2012 18:12
what is the value of Exchangeconnectionmode right before you call getselectnamesdialog in your c# code?
-
jueves, 02 de agosto de 2012 19:07ModeradorI put this in the Form1 startup code in a new Windows Form application, and I didn't get any exceptions:
Outlook.
Application app = new Outlook.Application();Outlook.
NameSpace ns = app.GetNamespace("MAPI");ns.Logon(
"", "", false, false);Outlook.
SelectNamesDialog sel = ns.GetSelectNamesDialog();sel.Display();
On the machine where it's failing, can you run any other Outlook automation code at all? For example, can you open and display a new mail item? Do you have an up-to-date A-V on that machine and have the automation settings set to allow running code with Outlook?
"Seth Jensen" <=?utf-8?B?U2V0aCBKZW5zZW4=?=> wrote in message news:0ef89eae-ab87-4daa-a3eb-71b22c35c172...I am connected, verified by the ExchangeConnectionMode field. I do not know what you mean by "Do you have the same problem when you start outlook normally as a user." I can start Outlook normally, do you mean in code? I am trying to run VBA code, but I am unfamiliar with VBA so it is going very far as of yet.
Ken Slovak MVP - Outlook -
jueves, 02 de agosto de 2012 19:51
I can successfully create and show a mailbox item. I am unsure what you mean by A-V settings, and where do I find automation settings. I am still new to Outlook in general, and cannot seem to find it. I did however realize the above settings in Trust Center, maybe this is the issue. Could it be a policy we have set forth that doesn't allow outside programs to access the GAL? I guess I might have to do it with a VBA macro.. Unless you can suggest another way to create an AddressEntry for a specific distribution list?
-
jueves, 02 de agosto de 2012 21:20ModeradorWhat are the settings in the Macro Security and Add-ins tabs?
In my Programmatic Access tab I have the "Warn me about suspicious activity..." radio selected.
I'm no Exchange admin, but in my own network I operate without restrictions. It appears some policy may be in effect as none of those radio buttons is selected.
Ken Slovak MVP - Outlook
-
jueves, 02 de agosto de 2012 21:30
-
viernes, 03 de agosto de 2012 14:52Moderador
I'd try 2 things, in this order.
First, if on the Macro Settings tab the checkbox for "apply macro settings to installed addins" is checked uncheck it. Restart Outlook and see if there's a difference.
Second, change the setting on the radio controls in the tab to "notifications for all macros" or "enable all macros".
If those changes make a difference, check to see if you are strong naming your assembly.
Ken Slovak MVP - Outlook
-
viernes, 03 de agosto de 2012 18:07
Apply macro settings to installed add-ins is not checked. I cannot change the Macro Security settings, it is disabled by group policy. What does it mean strong naming my assembly?
-
viernes, 03 de agosto de 2012 18:12Moderador
Strong naming is signing the assembly with a code signing certificate, on the project Properties Signing tab.My guess is that your problem is the result of one or more group policies applied by your admins. I'd check with them as to the permissions needed to run Outlook automation code."Seth Jensen" <=?utf-8?B?U2V0aCBKZW5zZW4=?=> wrote in message news:cbee250c-9ef9-42f2-ae1f-c4e3c89ce172...Apply macro settings to installed add-ins is not checked. I cannot change the Macro Security settings, it is disabled by group policy. What does it mean strong naming my assembly?
Ken Slovak MVP - Outlook- Marcado como respuesta Tom_Xu_WXModerator martes, 07 de agosto de 2012 8:44

