protected override void ExecuteCrmWorkFlowActivity(CodeActivityContext context, LocalWorkflowContext localContext)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (localContext == null)
            {
                throw new ArgumentNullException(nameof(localContext));
            }

            EntityReference emailToCheck = EmailToCheck.Get(context);

            int count = GetAttachmentCount(localContext.OrganizationService, emailToCheck.Id);

            AttachmentCount.Set(context, count);
            HasAttachments.Set(context, count > 0);
        }
        protected override void Execute(CodeActivityContext executionContext)
        {
            ITracingService             tracer         = executionContext.GetExtension <ITracingService>();
            IWorkflowContext            context        = executionContext.GetExtension <IWorkflowContext>();
            IOrganizationServiceFactory serviceFactory = executionContext.GetExtension <IOrganizationServiceFactory>();
            IOrganizationService        service        = serviceFactory.CreateOrganizationService(context.UserId);

            try
            {
                EntityReference emailToCheck = EmailToCheck.Get(executionContext);

                int count = GetAttachmentCount(service, emailToCheck.Id);

                AttachmentCount.Set(executionContext, count);
                HasAttachments.Set(executionContext, count > 0);
            }
            catch (Exception ex)
            {
                tracer.Trace("Exception: {0}", ex.ToString());
            }
        }