Guid emailObjectID = new Guid();
if (contact != null)
{
Entity toactivityParty = new Entity();
toactivityParty.LogicalName = "activityparty";
toactivityParty.Attributes["partyid"] = contact;
toEntities.Add(toactivityParty);
}
else if (contact == null && lead != null)
{
Entity toactivityParty1 = new Entity();
toactivityParty1.LogicalName = "activityparty";
toactivityParty1.Attributes["partyid"] = new EntityReference("lead",lead.Id);
toEntities.Add(toactivityParty1);
}
Entity oEmail = new Entity();
oEmail.LogicalName = "email";
oEmail.Attributes["to"] = toEntities.ToArray();
emailObjectID = service.Create(oEmail);
but this is not creating email with email[to] = lead but the same is successful with email[to]=contact. Can anyone please help?
how to assign lead to email..........?