다음을 통해 공유


Create an e-mail Activity into CRM using SDK.

Lets see how to create an e-mail activity using CRM IOrganization service.

var emailEntity = new Entity("email");

emailEntity["subject"] = "test subject";
emailEntity["description"] = " test description";

var recipient = new Entity();
var sender = new Entity();

recipient = new Entity("activityparty");
recipient["partyid"] = new EntityReference("lead", new Guid("idOfTheLead"));

Entity[] toRecipients = { recipient };
emailEntity["to"] = toRecipients ;

sender = new Entity("activityparty");
sender ["partyid"] = new EntityReference("systemuser", new Guid("idOfTheUser"));
Entity[] from = { sender };
emailEntity["from"] = from ;

emailEntity["regardingobjectid"] = new EntityReference("lead", new Guid("idOfTheLead"));

service.Create(emailEntity);