By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,052 Members | 1,551 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,052 IT Pros & Developers. It's quick & easy.

Having trouble with Environment.NewLine in email body

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.