sitecore Engagement Automation Enroll contact in the engagement plan programmatically


Example

 AutomationMetadataProvider automationMetadataProvider = Assert.ResultNotNull(Factory.CreateObject("automation/metadataProvider", true) as AutomationMetadataProvider);            
 var context = AutomationManager.Provider.GetAutomationContext(ID.Parse(contact.ContactId));            
 context.Enroll(fromStateItem.ParentID, ID.Parse(fromState), automationMetadataProvider.CalculateWakeUpDateTime(ID.Parse(fromState), DateTime.UtcNow), null);
 AutomationManager.Provider.SaveAutomationContext(context);