Is it possible to generate html formatted emails with string variable in it?
for example:
<table><td>%StringVar</td></table>
Is it possible to generate html formatted emails with string variable in it?
for example:
<table><td>%StringVar</td></table>
Here is how to reference tokens within a script and to use them to build the HTML string. This code snippet also shows you how to expose the HTML token you will use in the email.
protected override void Execute() { StringBuilder htmlText = new StringBuilder(); htmlText.Append("<table>"); htmlText.Append(" <tr>"); htmlText.AppendFormat(" <td>{0}</td>", this.GetTokenValue("Token1")); htmlText.AppendFormat(" <td>{0}</td", this.GetTokenValue("Token2")); htmlText.Append(" </tr>"); htmlText.Append("</table>"); this.SetTokenValue("emailBody", htmlText.ToString()); } }
As for the Email activity you would reference the token you created in the script in the Token Dialog for the Email activity. You must also use the Token Dialog to format that token as HTML. Here are some screen snips;
In the Email activity;
In the Token Dialog;
Maxwell,
Are you asking how to create HTML text that contains workflow tokens using a Script activity or are you asking how to display HTML in the body of an email using the Email activity?
I am asking if I or How can I create a string with html tags in a script and pass the string to a token then use the token inside the email activity.
In the script you will need to return the HTML in a token.
SetTokenValue("HTML", sHTML)
And in the email body you will need to include the token like the following in the email activity.
%(HTML#"HTML"#)
Here is how to reference tokens within a script and to use them to build the HTML string. This code snippet also shows you how to expose the HTML token you will use in the email.
protected override void Execute() { StringBuilder htmlText = new StringBuilder(); htmlText.Append("<table>"); htmlText.Append(" <tr>"); htmlText.AppendFormat(" <td>{0}</td>", this.GetTokenValue("Token1")); htmlText.AppendFormat(" <td>{0}</td", this.GetTokenValue("Token2")); htmlText.Append(" </tr>"); htmlText.Append("</table>"); this.SetTokenValue("emailBody", htmlText.ToString()); } }
As for the Email activity you would reference the token you created in the script in the Token Dialog for the Email activity. You must also use the Token Dialog to format that token as HTML. Here are some screen snips;
In the Email activity;
In the Token Dialog;
This is exactly what I'm looking for! Thank You!