Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 82002

Prevent duplicate user in Email

$
0
0

Hi, i have requirement to create email in CRM using C#. 

The following is a piece of code used to get the list of recipients.

for (int iusr = 0; iusr < dtableUserQuality.Rows.Count; iusr++)
{
systemuserid = Guid.Empty;
systemuserid = new Guid(dtableUserQuality.Rows[iusr][0].ToString());
QueryExpression to_query = new QueryExpression("systemuser");
to_query.Criteria = new FilterExpression();
to_query.Criteria.AddCondition("systemuserid", ConditionOperator.Equal, systemuserid);
to_query.ColumnSet = new ColumnSet(true);

EntityCollection to_colect_email = _service.RetrieveMultiple(to_query);


toUserParty.EntityName = "systemuser";

foreach (Entity to_ent_email in to_colect_email.Entities)
{
string fullname = to_ent_email.GetAttributeValue<String>("fullname");



Entity fromParty = new Entity("activityparty");
EntityReference userParty = new EntityReference("systemuser", to_ent_email.Id);

fromParty.Attributes.Add("partyid", userParty);

toUserParty.Entities.Add(fromParty);

}
}

if (toUserParty.Entities.Count > 0)
{
email.Attributes.Add("to", toUserParty);
}

The email created succesfully, however the code allowed duplicate user exist in the recepients list. 

how to prevent users already in the recipient list from being duplicated.

Thanks


Viewing all articles
Browse latest Browse all 82002

Latest Images

Trending Articles



Latest Images