I have developed an intranet application , In which a dropdownlist is binded with outlook's global address list data . The code is as shown below :
Dictionary list = new Dictionary(); // Create the Outlook application. Microsoft.Office.Interop.Outlook.Application oApp = new Microsoft.Office.Interop.Outlook.Application();
// Get the NameSpace information.
Microsoft.Office.Interop.Outlook.NameSpace oNS = oApp.GetNamespace("mapi");
// oNS.Logon(oNS.CurrentProfileName, "*********", true, true);
// Get the default Contacts folder.
Microsoft.Office.Interop.Outlook.MAPIFolder oContacts = oNS.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderContacts);
// Microsoft.Office.Interop.Outlook.AddressLists = oNS.AddressLists;
// Get the Items collection from the folder.
Microsoft.Office.Interop.Outlook.Items oItems = (Microsoft.Office.Interop.Outlook.Items)oContacts.Items;
Microsoft.Office.Interop.Outlook.ContactItem oCt = (Microsoft.Office.Interop.Outlook.ContactItem)oItems.GetFirst();
Microsoft.Office.Interop.Outlook.AddressLists addressbook=oNS.AddressLists;
Microsoft.Office.Interop.Outlook.AddressList addrList = oNS.GetGlobalAddressList();
foreach (Microsoft.Office.Interop.Outlook.AddressEntry addentry in addrList.AddressEntries)
{
Microsoft.Office.Interop.Outlook.ExchangeUser contact = addentry.GetExchangeUser();
if(contact!=null)
list.Add(contact.PrimarySmtpAddress, addentry.Name);
// string email = contact.Email1Address;
}
((DropDownList)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Email")).DataSource = list;
((DropDownList)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Email")).DataTextField = "Key";
((DropDownList)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Email")).DataValueField = "Value";
((DropDownList)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Email")).DataBind();
}
catch (System.Exception ex)
{
}
The code is working fine in development system but gives error in server as System.Runtime.InteropServices.COMException (0x80010001): Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80010001.
The outllook is installed and configured to an Email account.
Please help in fixing the issue :
Do you have Outlook installed on the server that your intranet application is running on? If you do, please make sure that the Outlook components have the correct permissions on that machine.
A method that works,
try { outlook = new Outlook.Application(); }
catch { outlook = new Outlook.Application(); }
User contributions licensed under CC BY-SA 3.0