user1871697
user1871697

Reputation: 21

inserting table with rows and columns in the message body of email in ios

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.

Upvotes: 2

Views: 1670

Answers (1)

iDev
iDev

Reputation: 23278

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

Upvotes: 2

Related Questions