Wednesday, May 9, 2012

Customize the workflow mail

I have a workflow that sends a mail to the users when ever a list item is edited and a specific field is updated. I don't want the users to access the list, so I built a simple workflow to send a mail to them instead.
The challenge is to make the mail look like it does in the list item and with some extra branding added. To make this happen you need to add the HTML code in a very specific way, otherwise it will look like crap and the HTML code will be visible in the mail.

Add the "Send an email" action in the workflow
Click on "Advanced properties" in the ribbon, or hover the action and click on "Properties":

In there, click on the .. button on the Body row:
Now comes the important part: if you want to add your own css classes in a style tag, you need to remove ALL space in that style tag, otherwise they will be displayed in the mail and css is not incorporated. Like this:
You can have a space before the next .class, that works, but all other spaces needs to be removed.
Then just copy and paste the rest of the HTML code into the body and it should work fine.