[英]How to get all contacts of an Account and build an email List in MS Dynamics CRM?
我有一个帐户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;
}
您可以在联系人实体中找到客户键“ parentcustomerid”。 您可以按以下帐户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);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.