Having trouble with Environment.NewLine in email body

K

Kevin Blount

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?
 
K

Kevin Blount

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
use the html tag of <br> for new line since your email is set to html

Kevin Blount said:
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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top