CDO Mail Formatting

  • Thread starter Thread starter Ed Richter
  • Start date Start date
E

Ed Richter

I have a mail program that allows users to compose an email message in a text window, then when you click on a button to send, it goes to the next page and via an ASP script sends the message out to everyone on a distribution list. Everything was working great.

Then recently I converted the email to an html formatted message as there was some formatting that I wanted to use; bold in certain fields, italics other places, a more tabular layout by using tables, etc. All of the formatting and sending of the message again worked fine.

The only problem I seem to now have though is when you type anything in the message window and skip lines for paragraph breaks, when sending the message, all extra white space is eliminated except skipping one space between words. Is there a way I can have message sent using html mail, but not lose spacing? Seems that wasn't a problem prior when message was being sent as plain text??
 
An email message in HTML format is essentially a web page page displayed
by your email client. In HTML, carriage returns are treated as the space
character, and all extra space characters (including CRs) found in a
series are displayed as a single space character.

If you want to display extra space, you will need to include the space
entity " " (without quotes). If you want lines, you will need to
insert the line break tag "<br>". (Some HTML automatically include a
separation line at the end, but you usually enter pure text through forms.)

Now to answer your question, in the processing page, include in the code
a function to convert CR to BR tags and then run the text thru it before
you send it to your mail routine.

here's a function

Function showTextCrLf(OriginalString)
'replaces vbCrLf codes with <br>
'Add to databases as is. Use to replace retreived txt for HTML
originalString=originalString & ""
IF originalString ="" then
showTextCrLf= ""
ELSE
showTextCrLf= Replace(OriginalString, vbCRLF, "<br>")
End if
End Function
 
OK thanks, will give it a try. So what this function does then is if
it sees a plain single space as in between words, it just leaves it as
a plain single space. [IF originalString ="" then showTextCrLf= "" ]
But if it sees the CR charactor, it will replace that with the br?
[ELSE showTextCrLf= Replace(OriginalString, vbCRLF, "<br>")]

Just to clarify one point, in your function above,
[showTextCrLf(OriginalString)]you used an uppercase "O" But then
within the function you used lowercase "o"
[originalString=originalString & "" ] Is there any significance
between using the two, or was that just by accident?
 
Back
Top