【问题标题】:Use MFMailComposeViewController to compose HTML message [duplicate]使用 MFMailComposeViewController 编写 HTML 消息 [重复]
【发布时间】:2013-03-08 07:37:46
【问题描述】:

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

        [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 接收此邮件时,复选框根本不显示。

有什么我错过的吗?

谢谢。

【问题讨论】:

  • 我对 HTML 不是很熟悉。我不知道,我只是从某个网站复制了这些 HTML 代码来测试复选框是否有效。即使我删除了表单元素,它也不起作用。
  • 我在stackoverflow.com/questions/2094879/… 中找到了解决此问题的正确方法。

标签: ios mfmailcomposeviewcontroller


【解决方案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];
}

【讨论】:

    猜你喜欢
    • 2021-12-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-17
    • 2014-07-23
    • 2020-10-12
    • 2011-08-23
    • 2014-12-30
    相关资源
    最近更新 更多