cyclonebri
Well-known member
Hi everybody.
I am trying to get a handle on public folders that are in existance on an exchange server in order to get the global list of contacts that everyone has access to. I am running into problems because I am unable to determine how to get to these folders.
I tried iteration, doing the following:
private Outlook.Application oApp;
private Outlook._NameSpace oNameSpace;
private Outlook._Folders oFolders;
private Outlook.MAPIFolder myFolder;
private Outlook.MAPIFolder mySubFolder;
private string sUserName = null;
private string sPassword = null;
public OutlookFolderTesting()
{
//initiates a contact object
oApp = new Outlook.Application();
oNameSpace = oApp.GetNamespace("MAPI");
oFolders = oNameSpace.Folders;
oNameSpace.Logon(sUserName,sPassword,true,true);
for (int i=0; i<oFolders.Count; i++)
{
try
{
myFolder = oFolders.GetNext();
MessageBox.Show(myFolder.Name);
for (int j=0; j<myFolder.Folders.Count; j++)
{
mySubFolder = myFolder.Folders.GetNext();
MessageBox.Show(mySubFolder.Name);
}
}
catch(System.Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
}
}
However that returns an object reference not set for the object when it gets to the public folder object, and also the inner iteration for some reason returns only the contacts folder each time, but thats not really a big concern at this point. What is a big concern is getting connected to the Public Folders object and be able to dig into it to get to the global contact lists (multiple lists in multiple subfolders i.e. ITGlobalContacts, MarketingGlobalContacts, etc).
Does anyone have any insight into this matter? I appreciate any help or suggestions that could be offered. Thanks in advance!
Brian
I am trying to get a handle on public folders that are in existance on an exchange server in order to get the global list of contacts that everyone has access to. I am running into problems because I am unable to determine how to get to these folders.
I tried iteration, doing the following:
private Outlook.Application oApp;
private Outlook._NameSpace oNameSpace;
private Outlook._Folders oFolders;
private Outlook.MAPIFolder myFolder;
private Outlook.MAPIFolder mySubFolder;
private string sUserName = null;
private string sPassword = null;
public OutlookFolderTesting()
{
//initiates a contact object
oApp = new Outlook.Application();
oNameSpace = oApp.GetNamespace("MAPI");
oFolders = oNameSpace.Folders;
oNameSpace.Logon(sUserName,sPassword,true,true);
for (int i=0; i<oFolders.Count; i++)
{
try
{
myFolder = oFolders.GetNext();
MessageBox.Show(myFolder.Name);
for (int j=0; j<myFolder.Folders.Count; j++)
{
mySubFolder = myFolder.Folders.GetNext();
MessageBox.Show(mySubFolder.Name);
}
}
catch(System.Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
}
}
However that returns an object reference not set for the object when it gets to the public folder object, and also the inner iteration for some reason returns only the contacts folder each time, but thats not really a big concern at this point. What is a big concern is getting connected to the Public Folders object and be able to dig into it to get to the global contact lists (multiple lists in multiple subfolders i.e. ITGlobalContacts, MarketingGlobalContacts, etc).
Does anyone have any insight into this matter? I appreciate any help or suggestions that could be offered. Thanks in advance!
Brian