Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
|
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 7th, 2007, 10:50 AM
Friend of Wrox
 
Join Date: Aug 2006
Posts: 231
Thanks: 0
Thanked 1 Time in 1 Post
Default new line operator in c#

hello
i want to give new line operator in my coding in c#.
actually my program will send an email to user but i want one message in one line and second in another e.g
strBody = "Your Membership Type is " + MembershipType + "\n";

i put "\n" which is not working i am getting my email in one line only please suggest.

thanks......
__________________
thanks......
 
Old December 7th, 2007, 11:02 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Its quite likely that the problem isn't the C# code, but the email itself.

It might be that the email program required both a carriage return and a line feed to show a new line, e.g. "\r\n".

/- Sam Judson : Wrox Technical Editor -/
 
Old December 7th, 2007, 11:17 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

You can also employ System.Environment.NewLine

hth.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor :.
Wrox Books 24 x 7
================================================== =========
 
Old December 7th, 2007, 01:26 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

What format is the email in? Plain text or HTML?

-Peter
 
Old December 7th, 2007, 02:12 PM
Friend of Wrox
 
Join Date: Aug 2006
Posts: 231
Thanks: 0
Thanked 1 Time in 1 Post
Default

well i will apply above two options and let know.

My email format is Plain Text.

thanks......
 
Old December 8th, 2007, 04:07 AM
Friend of Wrox
 
Join Date: Aug 2006
Posts: 231
Thanks: 0
Thanked 1 Time in 1 Post
Default

please solve my problem.
i tried both solution
1) i put "\r\n"
strBody = "Your Membership Type is " + MembershipType + "\r\n";

2) use of System.Environment.NewLine

strBody = "Your Membership Type is " + MembershipType + System.Environment.NewLine;

Both are not working.
Please suggest.

thanks......
 
Old December 8th, 2007, 06:54 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

I'm assuming there is more to the strBody that just that one line?

i.e.

strBody += "The next line...";

/- Sam Judson : Wrox Technical Editor -/
 
Old December 8th, 2007, 08:03 AM
Friend of Wrox
 
Join Date: Aug 2006
Posts: 231
Thanks: 0
Thanked 1 Time in 1 Post
Default

yes there are so many lines in body of message, you are right but still i am not getting.

thanks......
 
Old December 8th, 2007, 09:29 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Let's focus on the receiving end of the message. How are you looking at the message? What mail reader? Is it possible that the problem isn't that the newline characters aren't there, but rather that your mail reader is ignoring them. Can you look at the raw source of the message to confirm that the newline characters are now there?

-Peter
 
Old December 11th, 2007, 03:03 AM
Friend of Wrox
 
Join Date: Aug 2006
Posts: 231
Thanks: 0
Thanked 1 Time in 1 Post
Default

Well planoie,
you were absolutely write, my mail reader was ignoring them when i use my other email id's, it works perfectely.
Thanks for all for solution.

thanks......





Similar Threads
Thread Thread Starter Forum Replies Last Post
Invalid operator for data type. Operator equals di Pusstiu SQL Server 2000 2 August 10th, 2007 04:51 AM
How to draw indicator line in owc line chart AlexOo General .NET 0 July 9th, 2007 10:32 PM
Reading a string from line by line vaidyapragati ASP.NET 2.0 Professional 1 May 3rd, 2007 08:43 AM
How to read file line by line in EVC++ iriskab Visual C++ 0 September 27th, 2006 01:39 PM
Reading line by line from a .txt file x_ray VB.NET 2002/2003 Basics 5 February 10th, 2006 01:55 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.