求助,关于outlook开发读取出错问题
在读取OUTLOOK联系人和组时,第一层都读正确了,
第一层组下面的人员基本信息和组信息,读取就出错,请各位帮助,谢谢
下面是代码:
Application app = new ApplicationClass();
NameSpace mynamespace = app.GetNamespace("MAPI");
MAPIFolder myFolder = mynamespace.GetDefaultFolder(OlDefaultFolders.olFolderContacts);
DistListItem itemGroup;
for (int k = 1; k <= myFolder.Items.Count; k++)
{
string str = myFolder.Items[k].GetType().ToString();
try
{
ContactItem Item = (ContactItem)myFolder.Items[k];
if (Item.FullName != null)
ListBox1.Items.Add(Item.FullName);
if (Item.Email1Address != null)
ListBox1.Items.Add(Item.Email1Address);
if (Item.BusinessTelephoneNumber != null)
ListBox1.Items.Add(Item.BusinessTelephoneNumber);
if (Item.MobileTelephoneNumber != null)
ListBox1.Items.Add(Item.MobileTelephoneNumber);
this.Response.Write(Item.FullName + "====" + Item.BusinessTelephoneNumber + "<br>");
}
catch
{
itemGroup = (DistListItem)myFolder.Items[k];
this.ListBox1.Items.Add(itemGroup.DLName);
DistListItem my = (DistListItem)myFolder.Items[itemGroup.DLName];
MAPIFolder myFolder11 = (MAPIFolder)myFolder.Items[k];
DistListItem itemGroup1;
for (int j = 1; j <= myFolder11.Items.Count; j++)
{
try
{
ContactItem Item1 = (ContactItem)myFolder11.Items[j];
if (Item1.FullName != null)
ListBox1.Items.Add(Item1.FullName);
}catch{
itemGroup1 = (DistListItem)myFolder11.Items[j];
this.ListBox1.Items.Add(itemGroup1.DLName);
}
}
}
}