求助,关于outlook开发读取出错问题

yijichao 2009-05-18 10:43:27
在读取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);
}
}


}
}
...全文
42 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
tulong403 2009-05-18
  • 打赏
  • 举报
回复
帮顶

62,266

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧