Solved

Retaining format from multiline textboxes into email

Posted on 2007-04-10
3
221 Views
Last Modified: 2010-04-15
ASP.Net 1.1 (not 2.0)
C# on Windows server & IIS

I have an ASP.Net application (contact page)
User chooses whom they wish to cotact from a short list of names with check boxes.
They then fill in a subject line, write a message (stringbuilder) in a multiline text box, click send and an email is generated and sent to each of the selected users.  Simple.

All works fine, except the message body appears as a single string.  
For example :
********************************
Here is text as it would appear in the text box as the user is typing their message.
Here is the next line
And another line break here for line number three, followed by a couple of spaces

then a thanks and
the useres name
*************************

However, when it goes from the app to the email, it all becomes a single line, like this

-----------------------
Here is text as it would appear in the text box as the user is typing their message.  Here is the next line And another line break here for line number three, followed by a couple of spaces then a thanks and the useres name
-----------------------


What do I need to do/use in order to get the retain the formatting (complete with line breaks) from the app to the email???

Thanks!
0
Comment
Question by:nbbit
3 Comments
 
LVL 18

Accepted Solution

by:
Elvio Lujan earned 500 total points
ID: 18884926
string s = "Here is text as it would appear in the text box as the user is typing their message.
Here is the next line
And another line break here for line number three, followed by a couple of spaces

then a thanks and
the useres name
"

s.Replace("\n", "<br>")
0
 
LVL 10

Expert Comment

by:MrClyfar
ID: 18885008
Hi there.

A quick look indicates to me that it could be the carriage return and line feed characters are missing from the email text when it get's emailed. When the text is added to the stringbuilder, you must take into account the ControlChars.CrLf characters.

In the routine you have for adding text to the stringbuilder, you should have a line that adds the ControlsChars.CrLf character pair into the stringbuilder. Then, when you do a ToString, those characters should allow you to format the text as it appears when the user wrote it.

You may have to do the append like this:

Append("" & ControlChars.CrLf)

since if you do Append(ControlChars.CrLf) then you might get an exception of incorrect argument type.

Try it and experiment with the code. Hope this helps.
Jas.
0
 

Author Comment

by:nbbit
ID: 18897579
First answer gets the prize.  
Thanks for your help lem - as soon as I saw it I was like "DUH! I knew that!"
Thanks for input MrClyfar.

Be well all!
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question