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)

Outlook email contains HTML code when sent from CRM case workflow.

(0) ShareShare
ReportReport
Posted on by

We have a workflow in place that sends a "Case Assignment" email to the intended recipient Outlook when the help desk receives a new ticket. For some reason the case assignment email contains HTML code for all of the font in the email. Does anyone know why this is happening and how to get rid of the HTML tags?

Any help would be greatly appreciated. I have included a screen shot for reference.

2502.HTML.JPG

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at

    Check and see if you have an un-closed tags in the email created by the workflow.  Maybe there is a < or > in there somewhere that is causing it to exposed the hidden markup.

    Sometimes just opening the workflow step to send the email and re-saving it will fix these weird issues.

  • Community Member Profile Picture
    on at

    Hey Chris,

    Thanks for the response. How do I check the email created by the workflow? In Outlook? I am in the workflow properties right now and don't see anything about formatting or the creation of the case assignment email. Is there something I can put into the case assignment email template that would help get rid of the tags?

  • Community Member Profile Picture
    on at

    You need to de-activate the workflow, go to the step that sends the email, and review the text of the email that is getting sent.  There may be some invalid characters somewhere in that email.

  • Community Member Profile Picture
    on at

    I just deactivated the work flow and went to the step that sends the email. We have an email template that we use and that's what is used for the email. I have attached an image so you can see the template.

    5047.workflow.JPG

  • Community Member Profile Picture
    on at

    Actually, now that I am looking at it again...the issue may be with some characters in the case description.  The font tags appear right after the 'Description:' label, so perhaps there is something in that case description that is causing the problem?

    Does this problem happen on ALL case emails, or just some?

  • Community Member Profile Picture
    on at

    This is with all case emails. I believe this also happens with the email that the user gets back letting them know we have received the case. I am not sure if this happens in any another email platform, because we only use Outlook.

  • Community Member Profile Picture
    on at

    If you look at the case description on the case form, do you see all those Font tags?  How about a screen shot of an original case description on the case form?

  • Community Member Profile Picture
    on at

    The case description box on the case form is hidden, because I have a web resource in place that strips the HTML tags when the case description is populated via Outlook email. Previously, before I added the web resource the original case description box contained all of the HTML tags for the Outlook email.

  • Community Member Profile Picture
    on at

    So that may be the root of your problem then.  The case description has those font tags in it.  Incoming emails will have the tags and if you aren't stripping them out properly, then the case description will still have them, and the email notice from the workflow will have them.

    Check your code that strips out the tags.

  • Community Member Profile Picture
    on at

    This is the code that is in the web resource for the HTML tag stripping. I don't think that this effects the email because the emails contained HTML tags long before I put this in place. Also, this is a separate field on the case form it is not placed in the actual description box. This is the only thing I have found that gets rid of the HTML tags for the description on the case form.

    Would I need to put something in the actual CRM provided description box to get rid of these HTML tags? The email grabs what is in the description box and then uses that to generate the case assignment email?

    <!DOCTYPE html>

    <html lang="en">

    <head>

       <meta charset="UTF-8">

       <title>Email Body</title>

    </head>

    <body>

       <h3>Case Description</h3>

       <div id="description"></div>

    </body>

    <script>

       var RYR = window.RYR || {};

       var Xrm = parent.Xrm;

       RYR.retrieveEntityWebApi = function(entityName,recordId,additionalCriteria) {

           var headers = new Headers({

           "Accept": "application/json",

           "Content-Type": "application/json; charset=utf-8",

           "OData-MaxVersion": "4.0",

           "OData-Version": "4.0"

           });

           fetch("/api/data/v8.0/"+entityName+"?$select=activityid,description&$filter=_regardingobjectid_value eq "+recordId,

           {   method: 'GET',

               headers: headers,

               credentials: 'include' //without this header, the request will fail

           })

           .then(function(response){

               return response.json();

           })

           .then(function(c){

               if(c.value && c.value.length > 0) {

                   document.getElementById('description').innerHTML = c.value[0].description;

                   Xrm.Page.ui.tabs.get('general').sections.get('emailsection').setVisible(true);

               }

           })

           .catch(function(err) {

               console.log(err);

           });

       };

       RYR.retrieveEntityOData = function(entityName,recordId,additionalCriteria,callback) {

           var odataUrl = "/XRMServices/2011/OrganizationData.svc/"+entityName+"?$select=ActivityId,Description&$filter=RegardingObjectId/Id eq (guid'"+recordId+"')";

           if(additionalCriteria) {

               odataUrl += additionalCriteria;

           }              

           var retrieveReq = new XMLHttpRequest();

           retrieveReq.open("GET", odataUrl, false);

           retrieveReq.setRequestHeader("Accept", "application/json");

           retrieveReq.setRequestHeader("Content-Type", "application/json; charset=utf-8");

           retrieveReq.onreadystatechange = function () {

               if(callback) {

                   callback(this);

               }

           };

           retrieveReq.send();

       };  

       var processEmailResults = function (response) {

               if (response.readyState == 4) {

                   var emails = JSON.parse(response.responseText).d.results;

                   if(emails.length > 0) {

                       document.getElementById('description').innerHTML = emails[0].Description;

                       Xrm.Page.ui.tabs.get('general').sections.get('emailsection').setVisible(true);

                   }

               }

       };

       var retrieveEmailBody = function() {

           var recordId = Xrm.Page.data.entity.getId().substr(1,36);//Get rid of '{' and '}'

           if(!window.fetch ||

               !Xrm.Page.context.getVersion ||

               Xrm.Page.context.getVersion().split('.')[0] !== '8') {

               RYR.retrieveEntityOData('EmailSet',recordId,'&$top=1&$orderby=CreatedOn',processEmailResults);

           }

           else {

               RYR.retrieveEntityWebApi('emails',recordId,'&$top=1&$orderby=CreatedOn');

           }

       };

       if(Xrm.Page.ui.getFormType() === 2) retrieveEmailBody();

       window.RYR = RYR;

    </script>

    </html>

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