0

I could create the table. But not able to pass the value to table.

 - (IBAction)openMail:(id)sender {
    if ([MFMailComposeViewController canSendMail])
    {
        MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init];
        mailer.mailComposeDelegate = self;
        [mailer setSubject:@"Shopping Cart "];


        NSArray *toRecipients = [NSArray arrayWithObjects:@"fisrtMail@example.com", @"secondMail@example.com", nil];
       [mailer setToRecipients:toRecipients];
       NSString *e=self.phone;
       NSString *f=self.cost;
      //NSString *emailBody = [NSString stringWithFormat:@"%@%@%@%@",e,@"  ",f,@"  has been purchased successfully"];


    NSString *emailBody=@"<html> <table border=1>      <thead><tr><td>Item</td><td>Name</td><td>Qty</td><td>Price</td></tr></thead><tbody><tr><td>1</td><td>1</td><td>One</td><td>One</td></tr><tr><td>2</td><td>Two</td><td>Two</td><td>Two</td></tr><tr><td>3</td><td>Three</td><td>Three</td><td>Three</td></tr><tr><td>4</td><td>Four</td><td>Four</td><td>Four</td></tr></tbody></table> </html> ";


    [mailer setMessageBody:emailBody isHTML:YES];
    [self presentModalViewController:mailer animated:YES];
    //[mailer release];
}

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.

Midhun MP
  • 103,496
  • 31
  • 153
  • 200

3 Answers3

0
NSString *emailBody=[NSString stringWithFormat:@"<html> <table border=1>      <thead><tr><td>Item</td><td>Phone</td><td>%@</td><td>Cost</td><td>%@><td>Name</td><td>Qty</td><td>Price</td></tr></thead><tbody><tr><td>1</td><td>1</td><td>One</td><td>One</td></tr><tr><td>2</td><td>Two</td><td>Two</td><td>Two</td></tr><tr><td>3</td><td>Three</td><td>Three</td><td>Three</td></tr><tr><td>4</td><td>Four</td><td>Four</td><td>Four</td></tr></tbody></table> </html> ",e,f];

in above code i set the e and f with value of Phone and cost see the code...

i hope this help you..

Paras Joshi
  • 20,427
  • 11
  • 57
  • 70
0

As per my understanding you need to pass your var(s) values in 'emailBody'. If I'm right than you just format your string like this:

Let say;

NSString *myHTMLString = @"some value you need to pass";
NSString *emailBody = [NSString stringWithFormat:@"<html><body><table><tr><td>%@</td><tr></table></body>",myHTMLString];

Please use above according to your HTML formatting.Here, I just give you an example.

Hope this is what you looking for.:)

Mohit_Jaiswal
  • 840
  • 6
  • 10
0

See:

NSString *body = [[NSString alloc] initWithFormat:@"<html><body><yourHtmlcode />%@ %@</body></html>", yourVar1, yourVar2];

You may also create your HTML body dynamically, using loop and concatenation.

Astral Walker
  • 113
  • 1
  • 1
  • 6