使用MFMailComposeViewController组合HTML消息

时间:2013-03-08 07:37:46

标签: ios mfmailcomposeviewcontroller

我想在我的电子邮件正文中为每个项添加一些复选框,这里有一些测试代码

        [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];

当出现MFMailComposeViewController时,将显示该复选框,但是当我使用mail.app接收此邮件时,该复选框根本不会显示。

我错过了什么吗?

感谢。

1 个答案:

答案 0 :(得分:1)

以下是您的解决方案:

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];

实施代表

- (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];
}