Outlook address book logic is not working for office version 2003

May 7, 2013 at 5:52 AM
Edited May 7, 2013 at 6:02 AM
Hi Experts,

I'm working on a application where users should be able to select user names from outlook address book. since the logic should support multiple office version i tried NetOffice. Code works fine in office 2007 and latest versions but it fails in office 2003, it throws an exception.
            //Initializing application object
            Application application = GetApplicationObject();
            
            //Initializing SelectNamesDialog from the current session
            __SelectNamesDialog snd = application.Session.GetSelectNamesDialog();__

            //Restricts multiple selections
            snd.AllowMultipleSelection = false;

            ////Disabling To, Cc, Bcc lists
            //snd.NumberOfRecipientSelectors = OlRecipientSelectors.olShowNone;

            //Set the global address list as default
            snd.InitialAddressList = application.Session.GetGlobalAddressList();
            snd.Display();

            //Return selected  recipients collection
            return snd.Recipients;
Exception is thrown at GetSelectNamesDialog() invocation. apparently its not supported in 2003 object model. Is there any work around supported by NetOffice to handle this ?


Exception

Runtime.InteropServices.COMException (0x80004005): See inner exception(s) for details. ---> System.Runtime.InteropServices.COMException (0x80020006): Unknown name. (Exception from HRESULT: 0x80020006 (DISP_E_UNKNOWNNAME))
at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at NetOffice.Invoker.MethodReturn(COMObject comObject, String name, Object[] paramsArray)
at NetOffice.Invoker.MethodReturn(COMObject comObject, String name, Object[] paramsArray)
at NetOffice.OutlookApi._NameSpace.GetSelectNamesDialog()
at OutlookTest1.Outlook2010AddressBook.SelectedRecipients() in C:\Users\kthiyagarajah\Desktop\NetOffice\NET 4.0\Examples\Outlook\C#\Examples\OutookExamples\Outlook2010AddressBook.cs:line 91
at OutlookTest1.Outlook2010AddressBook.SelectedRecipient() in C:\Users\kthiyagarajah\Desktop\NetOffice\NET 4.0\Examples\Outlook\C#\Examples\OutookExamples\Outlook2010AddressBook.cs:line 61
at OutlookTest1.Outlook2010AddressBook.SelectedContact() in C:\Users\kthiyagarajah\Desktop\NetOffice\NET 4.0\Examples\Outlook\C#\Examples\OutookExamples\Outlook2010AddressBook.cs:line 51
at OutlookExamplesCS4.Example01.buttonStartExample_Click(Object sender, EventArgs e) in C:\Users\kthiyagarajah\Desktop\NetOffice\NET 4.0\Examples\Outlook\C#\Examples\OutookExamples\Examples\Example01.cs:line 62
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


Appreciate your help on this
kuru.
Coordinator
May 9, 2013 at 8:46 PM
i cant modify outlook of course. NetOffice helps you a lot to analyze problems in this direction. thats all.

Sebastian