Here i retrieve email id in the "to" field of email activity.
Entity entity = context.InputParameters["Target"] as Entity;
if (entity.LogicalName != "email")
return;
Email email = entity.ToEntity<Email>();
string to = string.Empty;
ColumnSet col = new ColumnSet("to");
entity = service.Retrieve(entity.LogicalName, entity.Id, col);
Guid partyId = new Guid();
EntityCollection Recipients = entity.GetAttributeValue<EntityCollection>("to");
foreach (var party in Recipients.Entities)
{
partyId = party.GetAttributeValue<EntityReference>("partyid").Id;
}
ColumnSet column = new ColumnSet("emailaddress1");
Entity toRecipent= service.Retrieve("contact", partyId, column);
Contact contact = toRecipent.ToEntity<Contact>();
to = contact.EMailAddress1;
Entity entity = context.InputParameters["Target"] as Entity;
if (entity.LogicalName != "email")
return;
Email email = entity.ToEntity<Email>();
string to = string.Empty;
ColumnSet col = new ColumnSet("to");
entity = service.Retrieve(entity.LogicalName, entity.Id, col);
Guid partyId = new Guid();
EntityCollection Recipients = entity.GetAttributeValue<EntityCollection>("to");
foreach (var party in Recipients.Entities)
{
partyId = party.GetAttributeValue<EntityReference>("partyid").Id;
}
ColumnSet column = new ColumnSet("emailaddress1");
Entity toRecipent= service.Retrieve("contact", partyId, column);
Contact contact = toRecipent.ToEntity<Contact>();
to = contact.EMailAddress1;
No comments:
Post a Comment