Hello, I am trying to create a custom workflow to attach notes attachment and send it. I am stuck at the conversion. I cant get around it. Please help! I have highlighted the error below.
[Input("SourceEmail")]
[ReferenceTarget("systemuser")]
public InArgument<EntityReference> SourceEmail { get; set; }
[Input("TargetEmail")]
[ReferenceTarget("systemuser")]
public InArgument<EntityReference> TargetEmail { get; set; }
[Input("Subject")]
public InArgument<string> Subject { get; set; }
[Input("Description")]
public InArgument<string> Description { get; set; }
protected override void Execute(CodeActivityContext executionContext)
{
// Get workflow context
IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();
//Create service factory
IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();
// Create Organization service
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
// Get the target entity from the context
Entity Attachid = service.Retrieve("activitypointer", context.PrimaryEntityId, new ColumnSet(new string[] { "activityid" }));
Guid emailid = Guid.Empty;
Entity email = new Entity("email");
Entity fromParty = new Entity("activityparty");
Entity toParty = new Entity("activityparty");
fromParty["partyid"] = new EntityReference(SourceEmail); <-------------Error Here------------>
email.Attributes["subject"] = Subject;
email.Attributes["description"] = Description;
emailid = service.Create(email);
AddAttachmentToEmailRecord(service, Attachid.Id,email);
*This post is locked for comments