D M
D M

Reputation: 320

Styles from E-Mails influence form css style

Track - Function

We are using the dynamics crm 2015 outlook add in to synchronize e-mails from Outlook to Dynamics CRM. With this tool, e-mails from Outlook can be attached to Dynamics CRM Entities.

Unfortunately some of the e-mails that users track contain inline css - styles. Somehow these styles aren't removed by dynamics CRM and now these embedded styles influence the standard - css of Dynamics CRM so it is no longer properly displayed.

Is there a way to disable all CSS - styles from those tracked e-mails or some other propability?

There already is a hint that script code is blocked, but it seems that css is not blocked... Can it be blocked to? script blocked but css styles not blocked

Dynamics CRM 2015 is used

Upvotes: 1

Views: 55

Answers (2)

D M
D M

Reputation: 320

To edit the mails that contained the css style the mails were opened by using

osp = new OrganizationServiceProxy(..)

Entity mailEnt = xrmServiceContext.EmailSet.Where(email => email.Subject.StartsWith("..."));

SetStateRequest ssr = new SetStateRequest();
ssr.EntityMoniker = new EntityReference(mailEnt.LogicalName, mailEnt.Id);
ssr.State = new OptionSetValue(0);
ssr.Status = new OptionSetValue(1);

then the body was edited using a replacement method

emailEnt["description"] = trimmedBody;
osp.Update(emailEnt);

finally the email states were set back to received

SetStateRequest ssr = new SetStateRequest();
ssr.EntityMoniker = new EntityReference(mailEnt.LogicalName, mailEnt.Id);
ssr.State = new OptionSetValue(1);
ssr.Status = new OptionSetValue(4); // 2 completed // 4 Received

Upvotes: 2

Probably you have to strip the CSS/HTML tags from the email body & store the plain text on email receipt.

Though this article is old but outlines the steps you have to follow.

You need a plugin in Email entity to run on DeliverPromote message (any e-mail promoted from Outlook triggers the "DeliverPromote" event), strip out the not-needed things from the Email body & store in CRM.

Upvotes: 1

Related Questions