Get distribution list address using Outlook 12.0 Object Library
.NET (Core and Framework)
1
Posts
1
Posters
0
Views
1
Watching
-
I'm trying to get the email addresses contained in a distribution list in a public folder using the Outlook 12.0 Object Library. I can get the distribution list (as Outlook._DistListItem), but can not figure out how to get the addresses contained in it. Does anyone have an idea/pointer that would help?
using Outlook = Microsoft.Office.Interop.Outlook; outlook = new Outlook.Application(); Outlook._NameSpace olNS = outlook.GetNamespace("MAPI"); Outlook.MAPIFolder oPublicFolder = olNS.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olPublicFoldersAllPublicFolders); Outlook.MAPIFolder tiFolder = null; foreach (Outlook.MAPIFolder currentFolder in oPublicFolder.Folders) { if ("DesiredFolder" == currentFolder.Name) { tiFolder = currentFolder; break; } } if (null != tiFolder) { Outlook._Items oItems = tiFolder.Items; for (int i = 1; i <= oItems.Count; i++) { try { Outlook._ContactItem oContact = (Outlook._ContactItem)oItems[i]; } catch (Exception ex) { try { Outlook._DistListItem distributionList = (Outlook._DistListItem)oItems[i]; // distributionList is thing I want; need to get members // :confused: :confused: :confused: } catch (Exception ex1) { } } }