Creating custom HTML eMails in SharePoint Designer 2010
When using SharePoint Designer 2010 to send out eMails people always complain so much about the disgusting plaintext looking emails. I get embarresed when I have just completed creating a wonderful workflow that does a complicated set of calculations and then trying to format this as an email message was rater disappointing.
So off to the web I went and searched my but off, spent days with many posts trying to put it all together, it seems that many people have the same issue that I had, after as I say many days of frustrations I eventually got some results. I am not an HTML guru, I manage my way around and use w3html school for most of my html questions, but this was a bit more of a problem than what I could resolve from there.
I was able to get the help of one of my collegues David Godfrey who is proficient with code and he helped me with a few lines of code and eventually I managed to get the results that I wanted and that was acceptable to our client.
The problem started when I said that I could build a Staff Alert system with SharePoint 2010. I had used a basic form of this 2 years before while I was training our IT staff to use SharePoint Designer and needed a project as a demonstration. The demonstration went well, but nobody would have accepted the emails that were sent out, they were just as bad as the manual staff alert emails that were being sent out at the time. So there was no improvement other than a record was being kept of each email.
Ok so enough of the backgroud let me get on with my solution.
So basically what I found out was I needed to make this work was a single line of html code with no breaks, and any line breaks that are required in the final mail needed to be hard coded html line breaks, any tables and formatting had to be in this same single line of code. My requirement also need some formatting so David added the css code in the head section of this line of html code.
What we ended up doing was basically creating 4 SharePoint variables (string type) one that contained the header and formatting tags, another that was populated with the code for the table and then inserted the fields from the lists within the table row tags and the last with the closing tags for the html code. I then used the fourth variable as a container for the first three variables without spaces and this was the only variable that was inserted into the SharePoint designer email message.
In the Next of this series I will give the variables, sample code and a description of what I used and what they do, and in the last article i will demonstrate how I put it all together in SharePoint Designer 2010.