Marketing automation - send email error

Martin Opletal asked on February 28, 2020 11:16

I have Marketing automation with Send marketing email step. And It's triggered by this code:

    var contact = ContactManagementContext.GetCurrentContact();
    contact.ContactEmail = email;
    var process = WorkflowInfoProvider.GetWorkflowInfo(workflowName, WorkflowTypeEnum.Automation);
    var manager = AutomationManager.GetInstance(MembershipContext.AuthenticatedUser);
    manager.StartProcess(contact, process.WorkflowID);

Solution contains three sites.

Everything works fine on local solution, but I get this Event log error in test environment:

  • Description: Processing contact 'Anonymous - 2020-02-28 09:35:16.993'. The email doesn't exist on the same site as the contact it is being sent to.

Any idea where problem may be?

Correct Answer

Michal Samuhel answered on February 28, 2020 20:55

You seem to be trying to a newsletter email. However, these emails are site objects which are assigned to a particular site. You seem to be triggering the action or whole process in context of a different site.

You can copy newsletters and emails to site which is running MA process. Or you can wrap action in CMSActionContext and set CurrentSite property for the context, but for this I can not guarantee behaviour of API and contextual properties as this was not thoroughly tested...

0 votesVote for this answer Unmark Correct answer

   Please, sign in to be able to submit a new answer.