I am trying to import the list of email addresses from Offline address list to a combo box, it seems to work fine in finding the List however, everytime I try to pull the data, it freezes the whole app, and when putting it into the Form_Load, the app refuses to come up.
I tried to Change to a textbox and issue remained the same. When trying a false address list, the app throughs an error that it can not find the list
private void button1_Click(object sender, EventArgs e)
{
Microsoft.Office.Interop.Outlook.Application app = new Microsoft.Office.Interop.Outlook.Application();
Microsoft.Office.Interop.Outlook.Accounts accounts = app.Session.Accounts;
Microsoft.Office.Interop.Outlook.NameSpace oNS = app.GetNamespace("mapi");
Microsoft.Office.Interop.Outlook.AddressLists oDLs = oNS.AddressLists;
Microsoft.Office.Interop.Outlook.AddressList oGAL = oDLs["Offline Global Address List"];
foreach (AddressEntry item in oGAL.AddressEntries)
{
comboBox1.Items.Add(item.Address);
}
}