Chinaunix首页 | 论坛 | 博客
  • 博客访问: 845919
  • 博文数量: 756
  • 博客积分: 40000
  • 博客等级: 大将
  • 技术积分: 4980
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-13 14:40
文章分类

全部博文(756)

文章存档

2011年(1)

2008年(755)

我的朋友

分类:

2008-10-13 16:09:16

Searching for the Richard Grimes Person
using(ItemContext ctx = ItemContext.Open())
{
   Folder myDataFolder = 
       UserDataFolder.FindMyPersonalContactsFolder(ctx);
   using (FindResult result = myDataFolder.GetAllMembers())
   {
      foreach (object o in result)
      {
         Person person = o as Person;
         if (person == null) continue;
         if (person.DisplayName == "Richard Grimes")
        {
            // use person here
            break;
         }
      }
   }
}

Incorrect Way to Add a Category
Person person = Person.CreatePersonalContact(ctx);
person.DisplayName = "Richard Edwards";
SmtpEmailAddress email;
email = new SmtpEmailAddress("dai@parkfarm.com");
email.Categories.Add(GeneralCategories.Home);
person.PersonalEmailAddresses.Add(email);
person.Save();
person = Person.CreatePersonalContact(ctx);
person.DisplayName = "Roberto Marchini";
email = new SmtpEmailAddress("rob@robshouse.com");
email.Categories.Add(GeneralCategories.Home);
person.PersonalEmailAddresses.Add(email);
person.Save();

Correct Way to Add a Category
Person person = Person.CreatePersonalContact(ctx);
person.DisplayName = "Richard Edwards";
SmtpEmailAddress email;
email = new SmtpEmailAddress("dai@parkfarm.com");
email.Categories.Add(new CategoryRef(GeneralCategories.Home));
person.PersonalEmailAddresses.Add(email);
person.Save();
person = Person.CreatePersonalContact(ctx);
person.DisplayName = "Roberto Marchini";
email = new SmtpEmailAddress("rob@robshouse.com");
email.Categories.Add(new CategoryRef(GeneralCategories.Home));
person.PersonalEmailAddresses.Add(email);
person.Save();


--------------------next---------------------

阅读(547) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~