473,387 Members | 1,456 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Having trouble with Environment.NewLine in email body

I've been trying all morning to find a way that will let me add new
lines to a string that will form the body of an email. The problem is
that some lines are not appearing as new line, but rather are being
appended to existing lines. Here's my (cut down) code:

string sbInstructions = string.Empty;
char endOfLine = '\n';

sbInstructions += "[Instructions]" + endOfLine;
sbInstructions += "DupCheck=email" + endOfLine;
sbInstructions += "SaveThis=" + gmEmailSubject + endOfLine;

int iLoopCount = 1;
do
{
sbInstructions += "OnNewSendEmail" + iLoopCount + "=" +
EmailSubject.Trim() + endOfLine;
sbInstructions += "OnDupSendEmail" + iLoopCount + "=" +
EmailSubject.Trim() + endOfLine;

sbInstructions += "cs" + iLoopCount + "_RecType=P" + endOfLine;
sbInstructions += "cs" + iLoopCount + "_Contact=P" + gmEmailSubject +
endOfLine;
} while (iLoopCount != contactsLoop);

In place of using endOfLine I've tried hard-coding '\n' and
Environment.NewLine, and I even tried using a StringBuilder and using
..AppendLine, but the result is this:

[Instructions]
DupCheck=email
SaveThis=Demo CD Request
OnNewSendEmail1=ESPDL,NEW,Demo CD Request OnDupSendEmail1=ESPDL,NEW,Demo
CD Request cs1_RecType=P cs1_Contact=test subject

where the result I need to this:

[Instructions]
DupCheck=email
SaveThis=Demo CD Request
OnNewSendEmail1=ESPDL,NEW,Demo CD Request
OnDupSendEmail1=ESPDL,NEW,Demo CD Request
cs1_RecType=P
cs1_Contact=test subject
any ideas why I can't get my new lines to work properly?
Sep 25 '06 #1
2 1555
Mel
use the html tag of <br for new line since your email is set to html

"Kevin Blount" <ke**********@LOLgmail.comwrote in message
news:Oq**************@TK2MSFTNGP03.phx.gbl...
I've been trying all morning to find a way that will let me add new lines
to a string that will form the body of an email. The problem is that some
lines are not appearing as new line, but rather are being appended to
existing lines. Here's my (cut down) code:

string sbInstructions = string.Empty;
char endOfLine = '\n';

sbInstructions += "[Instructions]" + endOfLine;
sbInstructions += "DupCheck=email" + endOfLine;
sbInstructions += "SaveThis=" + gmEmailSubject + endOfLine;

int iLoopCount = 1;
do
{
sbInstructions += "OnNewSendEmail" + iLoopCount + "=" +
EmailSubject.Trim() + endOfLine;
sbInstructions += "OnDupSendEmail" + iLoopCount + "=" +
EmailSubject.Trim() + endOfLine;

sbInstructions += "cs" + iLoopCount + "_RecType=P" + endOfLine;
sbInstructions += "cs" + iLoopCount + "_Contact=P" + gmEmailSubject +
endOfLine;
} while (iLoopCount != contactsLoop);

In place of using endOfLine I've tried hard-coding '\n' and
Environment.NewLine, and I even tried using a StringBuilder and using
.AppendLine, but the result is this:

[Instructions]
DupCheck=email
SaveThis=Demo CD Request
OnNewSendEmail1=ESPDL,NEW,Demo CD Request OnDupSendEmail1=ESPDL,NEW,Demo
CD Request cs1_RecType=P cs1_Contact=test subject

where the result I need to this:

[Instructions]
DupCheck=email
SaveThis=Demo CD Request
OnNewSendEmail1=ESPDL,NEW,Demo CD Request
OnDupSendEmail1=ESPDL,NEW,Demo CD Request
cs1_RecType=P
cs1_Contact=test subject
any ideas why I can't get my new lines to work properly?

Sep 25 '06 #2
Hi Mel,

Thanks for the reply. Unfortunately my email is not set to HTML, so
using "<br>" tags won't help here.

Any other ideas?

Kevin

Mel wrote:
use the html tag of <br for new line since your email is set to html

"Kevin Blount" <ke**********@LOLgmail.comwrote in message
news:Oq**************@TK2MSFTNGP03.phx.gbl...
>I've been trying all morning to find a way that will let me add new lines
to a string that will form the body of an email. The problem is that some
lines are not appearing as new line, but rather are being appended to
existing lines. Here's my (cut down) code:

string sbInstructions = string.Empty;
char endOfLine = '\n';

sbInstructions += "[Instructions]" + endOfLine;
sbInstructions += "DupCheck=email" + endOfLine;
sbInstructions += "SaveThis=" + gmEmailSubject + endOfLine;

int iLoopCount = 1;
do
{
sbInstructions += "OnNewSendEmail" + iLoopCount + "=" +
EmailSubject.Trim() + endOfLine;
sbInstructions += "OnDupSendEmail" + iLoopCount + "=" +
EmailSubject.Trim() + endOfLine;

sbInstructions += "cs" + iLoopCount + "_RecType=P" + endOfLine;
sbInstructions += "cs" + iLoopCount + "_Contact=P" + gmEmailSubject +
endOfLine;
} while (iLoopCount != contactsLoop);

In place of using endOfLine I've tried hard-coding '\n' and
Environment.NewLine, and I even tried using a StringBuilder and using
.AppendLine, but the result is this:

[Instructions]
DupCheck=email
SaveThis=Demo CD Request
OnNewSendEmail1=ESPDL,NEW,Demo CD Request OnDupSendEmail1=ESPDL,NEW,Demo
CD Request cs1_RecType=P cs1_Contact=test subject

where the result I need to this:

[Instructions]
DupCheck=email
SaveThis=Demo CD Request
OnNewSendEmail1=ESPDL,NEW,Demo CD Request
OnDupSendEmail1=ESPDL,NEW,Demo CD Request
cs1_RecType=P
cs1_Contact=test subject
any ideas why I can't get my new lines to work properly?

Sep 25 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Penn Markham | last post by:
Hello all, I am writing a script where I need to use the system() function to call htpasswd. I can do this just fine on the command line...works great (see attached file, test.php). When my...
2
by: AlexS | last post by:
Hello, I have error when reading schema using XmlSchema. Read and then .Compile: System.Xml.Schema.XmlSchemaException: May not be nominated as the {substitution group affiliation} of any...
5
by: Vamsi | last post by:
Hi, I am trying a basic opearation of splitting a multiline value to an array of single lines(Actually making Address into AddressLine1, AddressLine2). I used Environment.NewLine in split, I...
1
by: Asha | last post by:
greetings... i want to split a new line from an input text area and here's what i did string.Split("\n \r ", ","); the result, nothing happen... then i tried this ...
4
by: Peter Kirk | last post by:
Hi I would like to ask a little bit about the value Environment.Newline: what is it and what is the point of it? Ok, I can see in the docs that it represents "newline" for the current platform -...
2
by: Kevin Blount | last post by:
I've been trying all morning to find a way that will let me add new lines to a string that will form the body of an email. The problem is that some lines are not appearing as new line, but rather...
1
by: tshad | last post by:
Some of my regular expressions don't seem to work correctly in IE7. I am on asp.net 1.1. I have a site that has been up for a while and I started having problems on machines with IE7. IE5 and...
0
grassh0pp3r
by: grassh0pp3r | last post by:
Hello, I'm trying to make a very simple comments page on my site using PHP and am having problems somewhere. I am very new to PHP. I was able to create one that works with comments appended, but...
7
by: =?Utf-8?B?VGhlIE1hbiBGcm9tIFNRTA==?= | last post by:
I'm having the darndest problem and I can't seem to recreate it anywhere, and I'm looking for someone with a little insight. I've created a custom EmailTraceListener which implements the...
8
by: cutlass | last post by:
Need you assistance to anyone who is willing to offer. I have been working on this script and can't get it to work. The issue I'm having is the statement: function validateSender($Address)...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.