Send an email from a text variable

Hi everyone,

I was trying to send an email from a process model (with the "send e-mail" node) where the text to be sent is a text variable that you write in a a!paragraphField. The problem is that in email that you recieve, the linebreaks of the text variable disappears.

This is what you see in the a!paragraphField

And this is what you recieve in the email

In the setup of the email node, in the message body, I only put the process variable that I get from the interface with the text.

So can anybody help me to see the same structure in the a!paragraphField and in the final email?

Thank you!

Sergio.

  Discussion posts and replies are publicly visible

Parents
  • +1
    Certified Lead Developer

    Emails use HTML formatting, which inherently ignores basic line breaks (i.e. the char(10) and char(13) characters or any combination of the two).  You would need to write functionality to find and replace any char(10) linebreaks with the html equivalent, "<br/>".  While you're at it, it's also a good idea to sanitize 3 other problematic characters - "<", ">", and "&", each of which should be replaced by their HTML equivalents.

    What I've gradually come up with is a "sanitization" expression rule that usually looks something like this:

    a!localVariables(
      local!characters: {
        "&",
        ">",
        "<",
        char(10),
        char(13)
      }, /* the ordering of these is important. */
    
      local!replacements: {
        tohtml("&"),
        tohtml(">"),
        tohtml("<"),
        "<br/>",
        ""
      },
    
      reduce(
        fn!substitute,
        trim(ri!input),
        a!forEach(
          local!characters,
          {
            fv!item,
            local!replacements[fv!index]
          }
        )
      )
    )

  • Thanks it is what I want. The only problem is that when you try to put more than one space (like tab), it dosn't show in the email. Here I show you an example:

    The a!paragraphField

    The email:

    Thank you very much for your answer!

    Sergio

Reply Children