How to get the Email id in a pre (or post) create Case (aka Incident) plugin RRS feed

  • Question

  • The goal here is to get the received date of an email. This email will be converted to an case, and the received date will be displayed in the case form as a field.

    When an email is converted to a case (aka incident), from a email web form, a pre create plugin is triggered on my platform. This plugin is synchronous and sandboxed.

    I would like to retrieve the id of this converted email in my plugin so I can retrieve information about it and put some of it in my case.

    So far I tried to retrieve it like that:

    using (var entityContext = new EntityContext(localContext.OrganizationService))
        var sourceEmail = entityContext.EmailSet.FirstOrDefault((email) => email.Incident_Emails.Id == incident.Id);
        if (sourceEmail != null)
            var emailDate = sourceEmail.ActualEnd;

    But it sourceMail is null.

    If I switch the plugin mode to async, the sourceMail is ok. Unfortunately, this is not an acceptable solution because the case form will be shown to the user before the plugin has ran, and so the received email date will be empty.

    Thursday, June 19, 2014 11:32 AM


  • I did try post create and sync mode, but no emails retrieved.

    Finally I ended up doing the stuff in the PostUpdateEmail plugin, and retrieve the Case thanks to the RegardingObjectId.

    Thanks anyway for the answer !

    • Marked as answer by JM Alfonsi Monday, June 30, 2014 11:54 AM
    Monday, June 30, 2014 11:54 AM

All replies