Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use MFMailComposeViewController to compose HTML message [duplicate]

I want to add some checkbox to each item in my email body ,here is some testing code

        [mailPicker setMessageBody:@"<html>\
         <head>\
         <title> Insert title here </title>\
         <body> Insert the body of email here </body>.\
         <form>\
         <input type=\"checkbox\" /> I am a male <br />\
         <input type=\"checkbox\" /> I am a female\
         </form>\
         </html>" isHTML:YES];

the checkbox will be shown when the MFMailComposeViewController is presented, but when i receive this mail using mail.app, the checkbox does not shown at all.

Is there anything I missed?

thanks.

like image 790
flypig Avatar asked Mar 08 '26 16:03

flypig


1 Answers

Here is the Solution for you:

MFMailComposeViewController *mailController = [[MFMailComposeViewController alloc] init];
mailController.mailComposeDelegate = self;
NSString *emailBody = @"<p>Here Your HTML Code</p>";                         
[mailController setMessageBody:emailBody isHTML:YES]; 
[self mailController animated:YES completion:NO];

the implement the delegate

- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_0)
{
// Notifies users about errors associated with the interface

switch (result)

{
    case MFMailComposeResultCancelled:

        // message.text = @"Result: canceled";

        break;

    case MFMailComposeResultSaved:

        // message.text = @"Result: saved";

        break;

    case MFMailComposeResultSent:

        //   message.text = @"Result: sent";

        break;

    case MFMailComposeResultFailed:

        // message.text = @"Result: failed";

        break;

    default:

        //  message.text = @"Result: not sent";

        break;

}

[self dismissViewControllerAnimated:YES completion:NO];
}
like image 137
Saurabh Singh Avatar answered Mar 11 '26 07:03

Saurabh Singh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!