Entering line breaks in NSString
Asked Answered
R

3

7

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.

Resent answered 31/12, 2010 at 14:23 Comment(0)
R
11

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];
Regulator answered 31/12, 2010 at 17:27 Comment(0)
A
6

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

Atlanta answered 11/12, 2011 at 11:41 Comment(0)
C
2

Your messageBody is set to HTML what will mean that you need to add </ br> for line break, or set isHTML:NO

Conway answered 31/12, 2010 at 14:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.