web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

E-mail formatting

(0) ShareShare
ReportReport
Posted on by

I need to remove the HTML formatting from the email, after sending it through a plugin. Could someone please tell me what the e-mail sends back at "target"?

Print Plugin Registration tool:

2465.Sem-t_ED00_tulo2.png

Sample receipt of Target:

6740.Sem-t_ED00_tulo.png

When the "Target" comparison is made with NULL the system returns the error "The given key was not present in the dictionary." Can someone help me?

Thanks

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Mahendar Pal Profile Picture
    45,095 on at

    Hi,

    It seems in case of send message only emailid is what you will get under input parameter, please check this: mscrmuk.blogspot.in/.../plugin-parameters.html

    Thanks

  • Suggested answer
    Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    This is what the email Send context returns:

            protected void ExecutePostEmailSend(LocalPluginContext localContext)
            {
                if (localContext == null)
                {
                    throw new ArgumentNullException("localContext");
                }

                Guid emailId = (Guid)localContext.PluginExecutionContext.InputParameters["EmailId"];
             }

    If you need to get the Email Entity record, you need to call the Retrieve method on the email entity after the Action:

    Entity email = service.Retrieve("email", emailId, new ColumnSet("from", "to", "cc", "subject", "description"));

    Hope this helps.

  • Honan Gurgel Profile Picture
    on at

    I need to format the email by removing the HTML tags and give an update on the email with the only test description. Now I'm facing the problem of "Cannot update subject or description unless email is in draft status". Could someone help me?

  • Suggested answer
    Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    Hi Honan,

    This was not an issue in earlier releases of CRM, but in 2016/365, the email can only be modified if the status is draft.

    The easiest way is to set it as draft before making your changes, make the changes, and set it to Sent or Received again:

    SetState("email", emailId, ActivityStateCode.Open, EmailStatusReason.Draft);

    UpdateEmailFields(emailId);

    SetState("email", emailId, ActivityStateCode.Completed, EmailStatusReason.Sent);

    Here is your Set State function:

           public void SetState(string entityname, Guid entityid, ActivityStateCode state, EmailStatusReason status)

           {

               EntityReference moniker = new EntityReference();

               moniker.LogicalName = entityname;

               moniker.Id = entityid;

               SetStateRequest request = new SetStateRequest();

               request.EntityMoniker = moniker;

               request.State = new OptionSetValue((int)state);

               request.Status = new OptionSetValue((int)status);

               try

               {

                   SetStateResponse response = (SetStateResponse)OrganizationService.Execute(request);

               }

               catch (FaultException<OrganizationServiceFault> ex)

               {

                   throw new InvalidPluginExecutionException(ex);

               }

           }

    You can use the following Activity State/Status codes:

           enum ActivityStateCode : int

           { Open = 0, Completed = 1, Canceled = 2 }

           enum EmailStatusReason : int

           { Draft = 1, Completed = 2, Sent = 3, Received = 4, Canceled = 5, PendingSend = 6, Sending = 7, Failed = 8 }

    Hope this helps.

  • Honan Gurgel Profile Picture
    on at

    Thank you very much for the tip above, however we decided to leave for code activity in the email entity.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans