I have created email using MFMailComposeViewController method. I need to insert a table with rows and columns in the message body of email.So please help.
Asked
Active
Viewed 1,621 times
1 Answers
2
You can set html as the content body and use some html code to draw a table inside that.
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
NSString *emailBody = @"<html>....</html>"; //html code for drawing table
[picker setMessageBody:emailBody isHTML:YES];
To draw a table in html use something like,
<table border=1>
<thead><tr><td>#</td><td>Name</td></tr></thead>
<tbody>
<tr><td>1</td><td>One</td></tr>
<tr><td>2</td><td>Two</td></tr>
<tr><td>3</td><td>Three</td></tr>
<tr><td>4</td><td>Four</td></tr>
</tbody>
</table>
For more details on how to draw table using html code, you can check some stackoverflow questions such as HTML Table different number of columns in different rows
-
Thanks for ur reply. I could create the table. But not able to pass the value to table. NSString *e=self.phone; NSString *f=self.cost; NSString *emailBody=@"...."; I need to pass the value "e" as mentioned above and "f" to the table in html.How to do it? Can you please reply to it. – user1871697 Dec 03 '12 at 08:28
-
@user1871697, You can use `[NSString stringWithFormat:@"
", nameParam]` to append the strings. You need to join the above code with required values using this. You can use multiple `stringWithFormat` and then join all the strings using this. `%@` is the format to insert a string between another string as shown above. – iDev Dec 03 '12 at 16:45# %@