2014-12-06 45 views
0

的聯繫人組我創建了一個作業以從Web系統導入聯繫人進行交換。我正在將聯繫人導入到他們自己的文件夾中。我希望能夠將它們添加到該文件夾​​中的組。我已經創建了羣組並向他們添加了聯繫人,但無法弄清楚如何讓羣組顯示在除默認WellKnownFolderName.Contacts以外的任何文件夾中。這裏是我的代碼來創建聯繫人組,看起來像parentid是一個只讀屬性,是否有可能這樣做?在EWS中的聯繫人文件夾中創建非WellKnownFolderName.Contact

public static ContactGroup CreateContactGroup(string distributionList, ExchangeService service, FolderId folder) 
    { 
     try 
     { 
      ContactGroup cg = new ContactGroup(service); 
      cg.DisplayName = distributionList; 
      cg.Save(); 
      return cg; 
     } 
     catch (Exception e) 
     { 
      return null; 
     } 
    } 

回答

0

要創建一個聯絡小組在另一個聯繫人文件夾,你需要獲得該文件夾的FolderId,然後使用在保存超載例如,如果你有一個聯繫人文件夾下的聯繫人叫OtherContacts你可以使用這樣的事情找到,然後該文件夾中創建ContactGroup

 FolderView cfv = new FolderView(1000); 
     cfv.Traversal = FolderTraversal.Shallow; 
     SearchFilter cfFilter = new SearchFilter.IsEqualTo(FolderSchema.DisplayName,"OtherContacts"); 
     FolderId cntfld = new FolderId(WellKnownFolderName.Contacts, "[email protected]"); 
     FindFoldersResults ffcResult = service.FindFolders(cntfld, cfFilter, cfv); 
     if (ffcResult.Folders.Count == 1) { 
      ContactGroup cg = new ContactGroup(service); 
      cg.DisplayName = "TestCg"; 
      cg.Save(ffcResult.Folders[0].Id); 
     } 

乾杯 格倫

+0

這個工作......已經有文件夾ID,所以我並不需要任何的搜索代碼,但我敢肯定它會幫助其他人:-)謝謝你的幫助p – ForteDevelop 2014-12-10 04:58:37

相關問題