hi,
kindly find red color highlight error part.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Query;
using Microsoft.Xrm.Sdk.Messages;
using Microsoft.Xrm.Sdk.Workflow;
using Microsoft.Crm.Sdk.Messages;
using System.Activities;
using System.Runtime.Serialization;
namespace workflow1
{
public class class1: CodeActivity
{
protected override void Execute(CodeActivityContext context)
{
IWorkflowContext workflowcontext = context.GetExtension<IWorkflowContext>();
IOrganizationServiceFactory servicefactory=context.GetExtension<IOrganizationServiceFactory>();
IOrganizationService service = servicefactory.CreateOrganizationService(workflowcontext.UserId);
Entity entity = service.Retrieve(workflowcontext.PrimaryEntityName, workflowcontext.PrimaryEntityId, new ColumnSet("new_users"));
if (entity != null)
{
string name = entity.GetAttributeValue<EntityReference>("new_users").Name;
Guid id = entity.GetAttributeValue<EntityReference>("new_users").Id;
Entity email = new Entity("email");
Entity Fromparty = new Entity("activityparty");
Entity toparty = new Entity("activityparty");
toparty["partyid"] = new EntityReference("systemuser",id);
fromparty["partyid"] = new EntityReference("systemuser",workflowcontext.UserId);
Guid emailid = service.Create(email);
SendBulkMailRequest sendemailreq = new SendBulkMailRequest
{
EmailId = emailid,
TrackingToken = "",
Issuesend = true
};
SendEmailResponse sendemailresp = (SendEmailResponse)service.Execute(sendemailreq);
}
}
}
}