You are viewing limited content. For full access, please sign in.

Question

Posted to Laserfiche Lounge

how to generate email using script in workflow

asked on September 18, 2019

Is it possible to generate html formatted emails with string variable in it?

for example:

<table><td>%StringVar</td></table> 

0 0

Answer

SELECTED ANSWER
replied on September 19, 2019

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;

0 0

Replies

replied on September 19, 2019

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?

0 0
replied on September 19, 2019

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.

0 0
replied on September 19, 2019

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"#)

 

0 0
SELECTED ANSWER
replied on September 19, 2019

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;

0 0
replied on September 19, 2019

This is exactly what I'm looking for! Thank You!

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.