2013-03-08 67 views
2

我想一些复选框添加到每个项目在我的电子邮件的身体,这里是一些测试代码使用MFMailComposeViewController撰写HTML邮件

 [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,复选框根本不显示。

有什么我错过了吗?

谢谢。

+0

我不是很熟悉HTML。我不知道,我只是从一些网站复制这些HTML代码来测试复选框是否工作。即使我删除了表单元素,它也不起作用。 – flypig 2013-03-08 07:58:03

+0

我发现了正确的方法来解决这个问题http://stackoverflow.com/questions/2094879/send-an-html-formatted-email-using-mfmailcomposeviewcontroller。 – flypig 2013-03-08 07:58:26

回答

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