我是一个帐户ID,并且希望获得该帐户下的联系人集合以构建电子邮件列表。
//build up Email
private Email BuildEmail(ActivityParty allcontacts){.... build my emailhere}
private List<Entity> GetAllContactsFromAccountId(Guid accountId, List<Entity> toList)
{
//how can I get all the contacts here
foreach (Entity contact in Account.Contact.Entities)//????
{
Entity activityParty = new Entity("activityparty");
activityParty["partyid"] = new EntityReference("??", e.Id);
if (toList.Any(t => t.GetAttributeValue<EntityReference>("partyid").Id == e.Id)) continue;
toList.Add(activityParty);
}
return toList;
}
答案 0 :(得分:0)
您可以找到帐户密钥&#34; parentcustomerid&#34;在联系实体。您可以通过帐户ID获取联系人收集,如下所示。
private EntityCollection getContactByAccountId(IOrganizationService service, Guid accountId)
{
QueryExpression query = new QueryExpression("contact");
query.ColumnSet = new ColumnSet(new string[] { "contactid", "fullname" });
query.Criteria.AddCondition(new ConditionExpression("parentcustomerid", ConditionOperator.Equal, accountId))
return service.RetrieveMultiple(query);
}