Extra line break every 967 characters

R

Ryan

I have an application that is sending a HTML e-mail to users. The format is
getting messed up when it is displayed because Outlook appears to be adding
an extra line break every 967 characters (including spaces according to
Word's word count). For example the HTML from Outlook is:

<td>Approval has been requested by Joe Citizen (1234)'.</td>
</
tr>
<tr>
<td width="135"><b>Link:</b></td> <td>

or

<td width="135"><b>Approval Type:</b></td>
<td>Check thi
s out</td>
</tr>

I have checked and it is not my application doing this it is only when it
gets into Outlook that gets messed up.

Does anyone have any ideas?

Thanks
 
V

Vanguard

Ryan said:
I have an application that is sending a HTML e-mail to users. The
format is
getting messed up when it is displayed because Outlook appears to be
adding
an extra line break every 967 characters (including spaces according
to
Word's word count).


So why are you sending e-mails with overly long line lengths? Per RFC
2822, Internet Message Format, section 2.1.1, the recommended maximum
line length is 998 characters long. You should be slicing up your lines
to be shorter than that. Remember that HTML reduces multiple spaces to
a single space and that newlines are ignored unless coded. E-mails
should use quoted-printable format which physically limits the lines to
under, say, 72 characters longs (depends on what line length you
configure) but the logical line length can be longer. See RFC 2045,
section 6.7, on how quoted-printable format works to keep the physical
line length small but represent a long line length. HTML doesn't have
the line-length limitation. E-mail does. With proper indentation and
line wrapping of string values (at their space characters) or for
parameters within a tag, there is no need to be writing HTML code with
such ridiculously long lines in it. Make your code so a human could
actually read it (with the exception that you may need to wrap long
strings across lines and that multiple spaces are compressed to just one
space in HTML within strings, so wrapping and indenting won't add more
spaces to the string).
 
R

Ryan

Thank you for your informative reply.

1. It's not my code - I am just amending code that was provided to our
company.

2. Here is an excerpt from the code:

body += ' <td width="135"><b>Approval Id:</b></td>\n';
body += ' <td>' + approvalLine.ApprovalId + '</td>\n';
body += ' </tr>\n';
body += ' <tr>\n';
body += ' <td width="135"><b>Created:</b></td>\n';

From my understanding of the the "\n" creates a new line.

So while I fully get where you are coming from as far as I can tell the
lines are being broken up.

Both the code that creates the html and the html itself are both readable by
humans already.

What do you think?
 
P

Pat Willener

Windows New Line is different from other platforms NL. On Windows you
need to use both Carriage Return (0x0D) and Line Feed (0x0A), I believe
in this order. Don't know if \n is doing that, but I'm reasonably
certain that this is the source of your problem.
 
V

Vanguard

Ryan said:
Thank you for your informative reply.

1. It's not my code - I am just amending code that was provided to
our
company.

2. Here is an excerpt from the code:

body += ' <td width="135"><b>Approval Id:</b></td>\n';
body += ' <td>' + approvalLine.ApprovalId + '</td>\n';
body += ' </tr>\n';
body += ' <tr>\n';
body += ' <td width="135"><b>Created:</b></td>\n';

From my understanding of the the "\n" creates a new line.

So while I fully get where you are coming from as far as I can tell
the
lines are being broken up.

Wrong. I'm talking about the length of lines in the e-mail message.
The newline character ("\n") could be anywhere in the line. That
doesn't change the length of the line in the e-mail message. It marks
the end of the line in the *rendered* display of the HTML. What you see
rendered is NOT what is physcially coded. For all we know (I can't by
your examples if the lines that you show are anchored to the left edge
or somewhere off at the end of the line), the \n *character* in the HTML
code could be off over in position 23,368 in the physical line.

I wasn't talking about how the HTML renders. I was talking about the
physical line length (in an e-mail) for the *coding* of the HTML
content.
Both the code that creates the html and the html itself are both
readable by
humans already.

What do you think?

Super long lines (of code) are hard for humans to read not just due to
having to scroll around but because parameters can become disconnected
(the user won't remember what were the other parameters within a tag)
and you usually end up with multiple tags per physical line so it is
easy to miss some when reading through the HTML code. I said to make
the *code* easily readable by humans (which would probably end up
shortening the lines so they can more easily be deciphered), not to make
the rendered version readable.

HTML code is nothing but plain text. All e-mails get sent a plain text.
Whether RTF-, HTML-, or plain-text format, they are always in plain
text. HTML is plain-text with tags. MIME sections are plain-text
encodings of attached files. So disregarding that anything is HTML at
all in your e-mails, make sure the physical lines of the text contained
within your mails remains under the recommended 998 character length
(and probably a bit shorter than that, too).

I'm suggesting you keep the *text* within your *e-mail* message to
shorter line lengths. I didn't not mention what to do for HTML coding
regarding the line lengths in the rendered version of the text used to
code the display of the rendered version. You said that Outlook was
adding a linebreak at every 967th character. Well, is that in the
rendered version of your e-mail or is that in the raw text of your
e-mail message? If the problem is in the rendered version, it isn't an
Outlook problem. It is an Internet Explorer problem since Outlook
doesn't actually do the rendering. Outlook uses libraries from IE to
render HTML-formatted e-mails. What do those e-mails, after their
receipt, look like when you view them directly in IE rather than Outlook
call IE to render them?
 
P

Pat Willener

You're welcome; but it was really Vanguard who pointed out the source of
the problem - I merely added some minor details.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top