Discussion:
Email text newline (\n) not working
(too old to reply)
Andy
2007-11-14 22:28:00 UTC
Permalink
Hi

I'm coding a callout for the CRM 3.0, This callout creates emails and tasks.
When creating a new email of several text lines for some reason everything
is displayed in one single line.

for example I have the following code:

string subject = "Lorem ipsum dolor sit amet";

string description = "Dear " + owner.fullname + "\n\n" +
"Lorem ipsum dolor sit amet (click on Regarding to see its information)" +
"\n" +
"Shortly you will be assigned this as a task to be completed" + "\n\n" +
"Thanks";

SendEmailMessage(subject, description, owner.systemuserid.Value,
opportunityId);

I should get something like this:

Dear Jonh Smith

Lorem ipsum dolor sit amet (click on Regarding to see its information)
Shortly you will be assigned this as a task to be completed

Thanks

Instead I get this:

Dear Jonh Smith Lorem ipsum dolor sit amet (click on Regarding to see its
information) Shortly you will be assigned this as a task to be completed
Thanks

But when coding tasks I don't have that problem, the text is displayed
correctly.

Any idea what could be the problem?

Thanks.
George Doubinski
2007-11-15 02:05:49 UTC
Permalink
Hi Andy,

does using '\r\n' combination instead of a '\n' change anything?

Hope this helps
--
George Doubinski
CRM Certified Professional - Developer
Post by Andy
Hi
I'm coding a callout for the CRM 3.0, This callout creates emails and tasks.
When creating a new email of several text lines for some reason everything
is displayed in one single line.
string subject = "Lorem ipsum dolor sit amet";
string description = "Dear " + owner.fullname + "\n\n" +
"Lorem ipsum dolor sit amet (click on Regarding to see its information)" +
"\n" +
"Shortly you will be assigned this as a task to be completed" + "\n\n" +
"Thanks";
SendEmailMessage(subject, description, owner.systemuserid.Value,
opportunityId);
Dear Jonh Smith
Lorem ipsum dolor sit amet (click on Regarding to see its information)
Shortly you will be assigned this as a task to be completed
Thanks
Dear Jonh Smith Lorem ipsum dolor sit amet (click on Regarding to see its
information) Shortly you will be assigned this as a task to be completed
Thanks
But when coding tasks I don't have that problem, the text is displayed
correctly.
Any idea what could be the problem?
Thanks.
Andy
2007-11-15 04:24:01 UTC
Permalink
Yes, I tried that too but is still not working.

I also tried using a StringBuilder but is the same story.

And this happens when creating emails, if I use the same string to create a
Task it works fine.

Has anyone else had the same problem?

Here an example of the code that creates such emails.

...
string subject = "Lorem ipsum";

string description = "Dear " + owner.fullname + "\n\n" +
"Lorem ipsum (click on Regarding to see its information)" + "\n" +
"Shortly you lorem ipsum" + "\n\n" +
"Thanks";
...

email email = new email();

email.subject = subject;
email.description = description;
email.from = new activityparty[] {from};
email.to = new activityparty[] {to};
email.regardingobjectid = regardingId;

service.Create(email);
huib aarts (crm.atechnisch.nl)
2007-11-15 08:31:46 UTC
Permalink
Andy,

I have used single quotes '\n' and that worked fine for me.

see my post
http://crm.atechnisch.nl/comments.php?DiscussionID=24&page=1#Item_0


regards

Huib
Andy
2007-11-15 20:08:01 UTC
Permalink
Hi Huib

I read your post and it's very interesting, it gave me some ideas for future
customizations.

What you're using there is javascript on the client side, I'm coding a
callout wich is server-side code (specifically C# code) so I cannot use
single quotes.

But I found a way to work around this, so instead of using the \n character
I have to use html paragraphs < p>< /p> (or the < br> tag)

So this is how my string looks like now:

string description = "< p>Dear " + owner.fullname + "< /p>" +
"< p>Lorem ipsum (click on Regarding to see its information)" + "< /p>" +
"< p>Shortly you lorem ipsum< /p>" + "< br>< br>" +
"< p>Thanks< /p>";


Thanks.
unknown
2010-02-24 08:22:17 UTC
Permalink
Long after the fact, but maybe someone else sees this :P

string description = "Dear " + owner.fullname + Environment.NewLine;

works for me.



And wrote:

Email text newline (\n) not working
14-Nov-07

H

I'm coding a callout for the CRM 3.0, This callout creates emails and tasks.
When creating a new email of several text lines for some reason everything
is displayed in one single line

for example I have the following code

string subject = "Lorem ipsum dolor sit amet"

string description = "Dear " + owner.fullname + "\n\n" +
"Lorem ipsum dolor sit amet (click on Regarding to see its information)" +
"\n"
"Shortly you will be assigned this as a task to be completed" + "\n\n" +
"Thanks"

SendEmailMessage(subject, description, owner.systemuserid.Value,
opportunityId)

I should get something like this

Dear Jonh Smit

Lorem ipsum dolor sit amet (click on Regarding to see its information
Shortly you will be assigned this as a task to be complete

Thank

Instead I get this

Dear Jonh Smith Lorem ipsum dolor sit amet (click on Regarding to see its
information) Shortly you will be assigned this as a task to be completed
Thank

But when coding tasks I don't have that problem, the text is displayed
correctly

Any idea what could be the problem

Thanks.

Previous Posts In This Thread:

On Wednesday, November 14, 2007 5:28 PM
And wrote:

Email text newline (\n) not working
H

I'm coding a callout for the CRM 3.0, This callout creates emails and tasks.
When creating a new email of several text lines for some reason everything
is displayed in one single line

for example I have the following code

string subject = "Lorem ipsum dolor sit amet"

string description = "Dear " + owner.fullname + "\n\n" +
"Lorem ipsum dolor sit amet (click on Regarding to see its information)" +
"\n"
"Shortly you will be assigned this as a task to be completed" + "\n\n" +
"Thanks"

SendEmailMessage(subject, description, owner.systemuserid.Value,
opportunityId)

I should get something like this

Dear Jonh Smit

Lorem ipsum dolor sit amet (click on Regarding to see its information
Shortly you will be assigned this as a task to be complete

Thank

Instead I get this

Dear Jonh Smith Lorem ipsum dolor sit amet (click on Regarding to see its
information) Shortly you will be assigned this as a task to be completed
Thank

But when coding tasks I don't have that problem, the text is displayed
correctly

Any idea what could be the problem

Thanks.

On Wednesday, November 14, 2007 9:05 PM
George Doubinski wrote:

Hi Andy,does using '\r\n' combination instead of a '\n' change anything?
Hi Andy

does using '\r\n' combination instead of a '\n' change anything

Hope this help
-
George Doubinsk
CRM Certified Professional - Developer

On Wednesday, November 14, 2007 11:24 PM
And wrote:

Yes, I tried that too but is still not working.
Yes, I tried that too but is still not working

I also tried using a StringBuilder but is the same story

And this happens when creating emails, if I use the same string to create a
Task it works fine

Has anyone else had the same problem

Here an example of the code that creates such emails

...
string subject = "Lorem ipsum"

string description = "Dear " + owner.fullname + "\n\n" +
"Lorem ipsum (click on Regarding to see its information)" + "\n" +
"Shortly you lorem ipsum" + "\n\n" +
"Thanks";
..

email email = new email()

email.subject = subject
email.description = description
email.from = new activityparty[] {from}
email.to = new activityparty[] {to}
email.regardingobjectid = regardingId

service.Create(email);

On Thursday, November 15, 2007 3:08 PM
And wrote:

Hi HuibI read your post and it's very interesting, it gave me some ideas for
Hi Hui

I read your post and it's very interesting, it gave me some ideas for future
customizations

What you're using there is javascript on the client side, I'm coding a
callout wich is server-side code (specifically C# code) so I cannot use
single quotes

But I found a way to work around this, so instead of using the \n character
I have to use html paragraphs < p>< /p> (or the < br> tag)

So this is how my string looks like now:

string description = "< p>Dear " + owner.fullname + "< /p>" +
"< p>Lorem ipsum (click on Regarding to see its information)" + "< /p>" +
"< p>Shortly you lorem ipsum< /p>" + "< br>< br>" +
"< p>Thanks< /p>";


Thanks.

On Friday, November 16, 2007 3:16 AM
huib aarts (crm.atechnisch.nl) wrote:

Andy,I have used single quotes '\n' and that worked fine for me.
Andy,

I have used single quotes '\n' and that worked fine for me.

see my post
http://crm.atechnisch.nl/comments.php?DiscussionID=24&page=1#Item_0


regards

Huib


Submitted via EggHeadCafe - Software Developer Portal of Choice
SharePoint List Usage and Statistics
http://www.eggheadcafe.com/tutorials/aspnet/892bae83-5b96-4275-95fd-9723a79fdb14/sharepoint-list-usage-and.aspx
unknown
2010-02-24 08:24:05 UTC
Permalink
Long after the fact, but maybe someone else sees this :P

string description = "Dear " + owner.fullname + Environment.NewLine;

works for me.



And wrote:

Email text newline (\n) not working
14-Nov-07

H

I'm coding a callout for the CRM 3.0, This callout creates emails and tasks.
When creating a new email of several text lines for some reason everything
is displayed in one single line

for example I have the following code

string subject = "Lorem ipsum dolor sit amet"

string description = "Dear " + owner.fullname + "\n\n" +
"Lorem ipsum dolor sit amet (click on Regarding to see its information)" +
"\n"
"Shortly you will be assigned this as a task to be completed" + "\n\n" +
"Thanks"

SendEmailMessage(subject, description, owner.systemuserid.Value,
opportunityId)

I should get something like this

Dear Jonh Smit

Lorem ipsum dolor sit amet (click on Regarding to see its information
Shortly you will be assigned this as a task to be complete

Thank

Instead I get this

Dear Jonh Smith Lorem ipsum dolor sit amet (click on Regarding to see its
information) Shortly you will be assigned this as a task to be completed
Thank

But when coding tasks I don't have that problem, the text is displayed
correctly

Any idea what could be the problem

Thanks.

Previous Posts In This Thread:

On Wednesday, November 14, 2007 5:28 PM
And wrote:

Email text newline (\n) not working
H

I'm coding a callout for the CRM 3.0, This callout creates emails and tasks.
When creating a new email of several text lines for some reason everything
is displayed in one single line

for example I have the following code

string subject = "Lorem ipsum dolor sit amet"

string description = "Dear " + owner.fullname + "\n\n" +
"Lorem ipsum dolor sit amet (click on Regarding to see its information)" +
"\n"
"Shortly you will be assigned this as a task to be completed" + "\n\n" +
"Thanks"

SendEmailMessage(subject, description, owner.systemuserid.Value,
opportunityId)

I should get something like this

Dear Jonh Smit

Lorem ipsum dolor sit amet (click on Regarding to see its information
Shortly you will be assigned this as a task to be complete

Thank

Instead I get this

Dear Jonh Smith Lorem ipsum dolor sit amet (click on Regarding to see its
information) Shortly you will be assigned this as a task to be completed
Thank

But when coding tasks I don't have that problem, the text is displayed
correctly

Any idea what could be the problem

Thanks.

On Wednesday, November 14, 2007 9:05 PM
George Doubinski wrote:

Hi Andy,does using '\r\n' combination instead of a '\n' change anything?
Hi Andy

does using '\r\n' combination instead of a '\n' change anything

Hope this help
-
George Doubinsk
CRM Certified Professional - Developer

On Wednesday, November 14, 2007 11:24 PM
And wrote:

Yes, I tried that too but is still not working.
Yes, I tried that too but is still not working

I also tried using a StringBuilder but is the same story

And this happens when creating emails, if I use the same string to create a
Task it works fine

Has anyone else had the same problem

Here an example of the code that creates such emails

...
string subject = "Lorem ipsum"

string description = "Dear " + owner.fullname + "\n\n" +
"Lorem ipsum (click on Regarding to see its information)" + "\n" +
"Shortly you lorem ipsum" + "\n\n" +
"Thanks";
..

email email = new email()

email.subject = subject
email.description = description
email.from = new activityparty[] {from}
email.to = new activityparty[] {to}
email.regardingobjectid = regardingId

service.Create(email);

On Thursday, November 15, 2007 3:08 PM
And wrote:

Hi HuibI read your post and it's very interesting, it gave me some ideas for
Hi Hui

I read your post and it's very interesting, it gave me some ideas for future
customizations

What you're using there is javascript on the client side, I'm coding a
callout wich is server-side code (specifically C# code) so I cannot use
single quotes

But I found a way to work around this, so instead of using the \n character
I have to use html paragraphs < p>< /p> (or the < br> tag)

So this is how my string looks like now:

string description = "< p>Dear " + owner.fullname + "< /p>" +
"< p>Lorem ipsum (click on Regarding to see its information)" + "< /p>" +
"< p>Shortly you lorem ipsum< /p>" + "< br>< br>" +
"< p>Thanks< /p>";


Thanks.

On Friday, November 16, 2007 3:16 AM
huib aarts (crm.atechnisch.nl) wrote:

Andy,I have used single quotes '\n' and that worked fine for me.
Andy,

I have used single quotes '\n' and that worked fine for me.

see my post
http://crm.atechnisch.nl/comments.php?DiscussionID=24&page=1#Item_0


regards

Huib

On Wednesday, February 24, 2010 3:21 AM
sluiper de waal wrote:

Environment.Newline
Long after the fact, but maybe someone else sees this :P

string description = "Dear " + owner.fullname + Environment.NewLine;

works for me.


Submitted via EggHeadCafe - Software Developer Portal of Choice
Join Lists with LINQ - SharePoint 2010
http://www.eggheadcafe.com/tutorials/aspnet/b0c1cd0d-fe82-444e-a16e-7d3fb7d38eca/join-lists-with-linq--sh.aspx
Continue reading on narkive:
Loading...