Storing New line character in SQL server 2005 and sending emails from C#.

Posted on 2009-04-30
Last Modified: 2012-05-06
I am storing the Email body in Sqlserver 2005 database and it needs to be sent in as text Email. I want some newline characters in the email body. I tried few characters but does not seem to be working.
Following is what I tried : \r\n, char(13)+char(10), char(10)+char(13).
Any help is highly ppreciated.
Question by:Faye_DBA
    LVL 3

    Assisted Solution


    MailMessage xx = new MailMessage();
    xx.BodyFormat = MailFormat.Html;
    xx.Body = "scscscs <br/> ";

    Accepted Solution

    I cannot have xx.BodyFormat = MailFormt.HTML, it has to be HTML.text only.
    So this solution will not work for me.
    Anyways I found the solution :
    when creating message body in sqlserver insert as

    insert into table_name (body)
    values ('this is First Line'+char(13)+char(10)+'this is Second Line')

    C# will automatically get the newline set between the two lines when it fetches the data from SqlServer.


    Featured Post

    Course: HTML5 Specialist

    HTML5 development skills are critical to all developers. HTML5 is the foundation to almost any development process. That's why business, design studios, development shops and other organizations need HTML5 developers. Get your foot in the door as a HTML5 specialist.

    Join & Write a Comment

          Install BugTracker on Windows 2008 server Step 1:  Install windows 2008 server 32 bit OS and configure IIS. Step 2:  Install SQL server ( SQL server 2005 or SQL server 2005 Express edition. The installer for 2008  version isn’t very f…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B. provides powerful tools for surveying targeted groups, and utilizing data from completed surveys to find trends, discover areas of demand or customer expectation, and make business decisions on products or services.
    Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…

    728 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

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now