Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Entering line breaks in NSString

I need to set mail Body in MFMailComposeViewController to separate some text in number of lines. I am using the following line of code but it isn't working.

[mail setMessageBody:[NSString stringWithFormat:@"Hi I am Interested to buy a vehicle for me Name :%@ %@ \n Contact No. : %@ \n Email : %@\n",txtFirst.text, txtLast.text, txtContact.text, txtEmail.text ] isHTML:YES];

also i tried this

[mail setMessageBody:[NSString stringWithFormat:@"Hi I am Interested to buy a vehicle for me Name :%@ %@ </br> Contact No. : %@ </br> Email : %@</br>",txtFirst.text, txtLast.text, txtContact.text, txtEmail.text ] isHTML:YES];

is there any solution to do it.

like image 828
Dipti Y W Avatar asked Dec 31 '10 14:12

Dipti Y W


2 Answers

Try this

[mail setMessageBody:
[NSString stringWithFormat:@"First:%@
                           \r\n Second:%@
                           \r\n Third:%@
                           \r\n Fourth:%@",
txtFirst.text, txtSecond.text, txtThird.text, txtFourth.text ] isHTML:YES];
like image 113
raaz Avatar answered Sep 21 '22 12:09

raaz


If you have isHTML set to YES in your message, use <br/> to do a line break, if isHTML is NO, use \r\n.

like image 39
foebe Avatar answered Sep 23 '22 12:09

foebe