Solved

Retaining format from multiline textboxes into email

Posted on 2007-04-10
3
227 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

724 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