public void TestCreateCustomEmail()
        {
            Entity contact = CreateContact();

            Entity          payment          = CreatePayment(contact);
            EntityReference paymentReference = payment.ToEntityReference();

            WhoAmIResponse whoAmI     = this.CrmOrganisationService.Execute(new WhoAmIRequest()) as WhoAmIResponse;
            Entity         whoAmIUser = new Entity("systemuser");

            whoAmIUser.Id = whoAmI.UserId;

            EntityReferenceCollection to = new EntityReferenceCollection();

            to.Add(contact.ToEntityReference());

            ITextProcessor crmTextProcessor = new TextProcessor(this.CrmOrganisationService);

            CreateCustomEmail createCustomEmail = new CreateCustomEmail(this.CrmOrganisationService, crmTextProcessor);

            createCustomEmail.CreateEmail(
                "DXTools Payment Notification Template"
                , whoAmI.UserId
                , paymentReference
                , paymentReference
                , new EntityReference("systemuser", whoAmI.UserId)
                , to
                , new string[] { "DXTools Payment Attachment Sample.docx", "DXTools Sample T&C.pdf" }
                , false
                , false);
        }
예제 #2
0
        public void InitialiseTests()
        {
            CrmConnection crmConnection = new CrmConnection("Xrm");

            CrmOrganisationService = new OrganizationService(crmConnection);

            CreateCustomEmailInstance = new CreateCustomEmail(CrmOrganisationService, null);
        }
        protected override void ExecuteActivity(CodeActivityContext executionContext)
        {
            string                    emailTemplateName = GetEmailTemplateName(executionContext);
            EntityReference           fromSender        = GetSender(executionContext);
            EntityReferenceCollection toRecipient       = GetRecipient(executionContext);
            EntityReference           regarding         = GetRegarding(executionContext);
            EntityReference           recordContext     = GetRecordContext(executionContext);

            string[] attachmentsArray                    = GetAttachments(executionContext);
            bool     allowDuplicateAttachments           = GetAllowDuplicateAttachments(executionContext);
            bool     onlyUseAttachmentsInTemplate        = GetOnlyUseAttachmentsInTemplate(executionContext);
            Dictionary <string, string> staticParameters = GetStaticParameters(executionContext);

            CreateCustomEmail createCustomEmail = new CreateCustomEmail(this.OrganizationService, new TextProcessor(this.OrganizationService));
            Entity            newEmail          = createCustomEmail.CreateEmail(emailTemplateName, this.WorkflowContext.UserId, staticParameters, recordContext, regarding, fromSender, toRecipient, attachmentsArray, allowDuplicateAttachments, onlyUseAttachmentsInTemplate);
            EntityReference   newEmailReference = newEmail.ToEntityReference();

            this.NewCreatedEmail.Set(executionContext, newEmailReference);

            SendEmail(newEmailReference, executionContext);
        }