Answered by:
Run plugin when Email status is Sent

Question
-
Hi,
I am trying to write a plugin that will run when the email status is changed to "Sent" but when I register the plugin for the "SetState" message or the "SetStateDynamicEntity" message it never runs.
What should I do here?
Thanks,
Dor.
Sunday, April 21, 2013 12:56 PM
Answers
-
Hi,
Because CRM first saves the emails and then sends them you could use the Send message for the emails in your plugin. You could use it as Pre Operation or Post Operation. This message passes the TrackingTocken, EmailID and IssueSend in the context.
- Proposed as answer by Payman BiukaghazadehEditor Sunday, April 21, 2013 2:18 PM
- Edited by Payman BiukaghazadehEditor Sunday, April 21, 2013 2:20 PM
- Marked as answer by Payman BiukaghazadehEditor Monday, April 22, 2013 8:41 PM
Sunday, April 21, 2013 2:18 PMModerator
All replies
-
Hi,
Because CRM first saves the emails and then sends them you could use the Send message for the emails in your plugin. You could use it as Pre Operation or Post Operation. This message passes the TrackingTocken, EmailID and IssueSend in the context.
- Proposed as answer by Payman BiukaghazadehEditor Sunday, April 21, 2013 2:18 PM
- Edited by Payman BiukaghazadehEditor Sunday, April 21, 2013 2:20 PM
- Marked as answer by Payman BiukaghazadehEditor Monday, April 22, 2013 8:41 PM
Sunday, April 21, 2013 2:18 PMModerator -
Hi,
Try registering pluign step for Send message on email entity inPre-Operation or Post-Operation stage, CRM saves email message and then fireSend message. The Message will pass EmailId, IssueSend and TrackingToken in context paramters. your code in plugin would be:
Guid jj_EmailId = Guid.Empty; bool jj_IssueSend = false; string jj_TrackingToken = string.Empty; switch (context.MessageName) { case "Send": if (context.InputParameters.Contains("EmailId") && context.InputParameters["EmailId"] is Guid) { jj_EmailId = (Guid)context.InputParameters["EmailId"]; } if (context.InputParameters.Contains("IssueSend") && context.InputParameters["IssueSend"] is bool) { jj_IssueSend = (bool)context.InputParameters["IssueSend"]; } if (context.InputParameters.Contains("TrackingToken") && context.InputParameters["TrackingToken"] is string) { jj_TrackingToken = (string)context.InputParameters["TrackingToken"]; } break; }
- Proposed as answer by Akhileshrajpoot Monday, April 22, 2013 4:50 AM
Monday, April 22, 2013 4:45 AM