Solved

Retaining format from multiline textboxes into email

Posted on 2007-04-10
3
223 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Business Impact of IT Communications

What are the business impacts of how well businesses communicate during an IT incident? Targeting, speed, and transparency all matter. Find out more in this infographic.

Question has a verified solution.

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

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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

732 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