Keeping Line Breaks in Email

I have a text box in which I concatenate several text boxes. I have line breaks indicated with Environment.NewLine. This then gets added as a new record to UD15. The line breaks are still in place. However, a BPM then used the entry in UD15 to send an email. The email text does not keep the Line Breaks. What do I need to do with my text in UD15 to keep the line breaks in the email body?

Did you try adding a carriage return too?

Edit: Never mind…

Environment.NewLine Property
“A string containing “\r\n” for non-Unix platforms, or a string containing “\n” for Unix platforms.”

If the email is HTML, you can use some HTML tags, perhaps

<br/>

If only the built-in email widgets had an HTML option …

Edit: I assume a widget is being used and not Custom Code. You can use custom code, to construct a nice HTML based email.

I am using custom code in a form to concatenate the text box together into one box. I am able to control the formatting there.

But the BPM uses an email widget, and the concatenated text is used in the email widget?

What I am doing in one of my custo is having a tag before each newline ([#line#]) for formating. Then, in the BPM, before the e-mail widget is used, I have a code widget that transforms all into a nice HTML format reading (and removing) the tags and copy all that into a callcontext character field. Which is then used in the body of the email widget.

works great.

Pierre

2 Likes

I create emails all the time, I’m usually using custom code. But I code my breaks with a \n in the string, such as: vBody = “This is line 1.\nThis is line 2.”; It sounds like your use of Environment.NewLine is equivalent.

It looks to me like you’re doing everything right. Going out on a limb, is there any chance your email is “leaving” Epicor correctly, but something else is removing the lines? Something on your email server or your email client?

A few other things you may want to try, just to troubleshoot:

  • Try \n instead of the Environment.NewLine field.
  • Try doubling up the new line: \n\n
  • Try a few of the other options: \r or \r\n
  • Rather than emailing your constructed text field, test an email where you are concatenating the fields with the new line within the email, not passing a field that already has it.
  • Look at your data that you’re saving (in hex format, for example). Perhaps it’s doing something with the new line as it’s storing the field.

Wow!! … Including the HTML framing (probably the wrong word) in the body of an email widget makes it HTML!!

How come I am just learning this now!!! :scream:

The “framing” required is

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
(This is an automated message. Please do not reply)
</body>
</html>

and you can define styles in the <head> section too!!!

5 Likes

But sadly does not work when using the email button for “printing a form”

image

.
and setting the email body as

image

Yields the following email

image

:frowning:
(not that I wanted to type - or even Copy & Paste that framing - stuff anyway)

Is there any other way to use the html tags in the email button for “printing a form”?

You might (emphasis on “might”) be able to intercept message body, with a BPM, and convert it to HTML. But doing that is just as hard (if not harder) as coding it in a BPM to begin with.

Can you please let me whether we can achieve this if yes can please explain us how to do this

After a little digging, I don’t think it is possible. And if it is, it would be an incredibly hard and convoluted solution.

As my post above state, you can put HTML tags in the body of an email generated by a BPM.

thanks for letting me know

Widget itself has no setting for you to set

message.IsBodyHtml = true;

I wonder if on your SMTP Server you can force Emails to be of type html instead of plain text.

A test I did was to put the HTML “stuff” in the body of the email widget,

Edit: Screen shot of DD

and it did come through. Here’s the email I received from a BPM that uses the email widget. Not the word “Please” is underlined and bolded (even though this font isn’t so great for making bold).

image

Maybe I just got lucky and Outlook decided to render that “embedded” HTML.

1 Like

Just to clarify something …

adding the html “framing”

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
(This is an automated message. Please do not reply)
</body>
</html>

only works in the email widgets of a BPM.

It does NOT work in the email widget of a Break/Routing… You get:

image

:frowning:

1 Like