I'm trying to create plugin that fires when an email is sent.
At first I tried using SetState and SetStateDynamicEntity to when the status is changed to completed. However the plugin never gets fired when an email is sent.
So I tried using the "Send" message using OnExecute method. Is it possible to retrieve the sent email entity info? I'm stumped in trying to return the Entity. The code below keeps returning "The given key was not present in the dictionary" error message.
I tried using either "Entity" or "EntityReference" but no luck.
I know that the Send message returns the EmailId. Is the only way to return the Entity from this EmailId?
public override void OnExecute(IServiceProvider serviceProvider, IPluginExecutionContext context) { var trace = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
if (!context.InputParameters.Contains("EmailId"))
{
return;
}
var emailId = (Guid)context.InputParameters["EmailId"];
Entity emailEntity = (Entity)context.InputParameters["Target"];