locked
Run plugin when Email status is Sent RRS feed

  • 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

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.



    My Weblog -- My Website


    Sunday, April 21, 2013 2:18 PM
    Moderator
  • 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;
        }
    
    Monday, April 22, 2013 4:45 AM