如何将html字符串传递给邮件正文

时间:2011-06-25 09:30:42

标签: iphone

我想通过电子邮件和短信选项向其他人发送特定消息。电子邮件部分工作得很好,但我不知道如何将html字符串传递到邮件正文中 对于消息,我使用的是MFMessageComposeViewController

,字符串就像

NSString *emailBody = [NSString stringWithFormat:@"<p>Map of %@</p><table><tbody><tr valign='top'><td><b>Place Name:</b></td><td>%@</td></tr><tr valign='top'><td><b>Country Name:</b></td><td>%@</td></tr><tr valign='top'><td><b>Area Name:</b></td><td>%@</td></tr><tr valign='top'><td><b>Latitude:</b></td><td>%@</td></tr><tr valign='top'><td><b>Longitude:</b></td><td>%@</td></tr><tr><td>&nbsp;</td><td>&nbsp;</td></tr></tbody></table>http://maps.google.com/maps?q=%@,%@</a><BR></BR>", [dict objectForKey:@"name"],[dict objectForKey:@"name"], [dict objectForKey:@"country"], [dict objectForKey:@"area"], [dict objectForKey:@"lat"], [dict objectForKey:@"long"],[dict objectForKey:@"lat"], [dict objectForKey:@"long"], [dict objectForKey:@"lat"],[dict objectForKey:@"long"]];  

如何将此字符串传递给消息控制器的setBody?

1 个答案:

答案 0 :(得分:1)

您确定已为MFMessageComposeViewController实例分配了委托对象吗?代表必须符合MFMessageComposeViewControllerDelegate协议。

要设置邮件的初始内容,请使用body属性。

以下是一个例子:

    MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
    picker.messageComposeDelegate = self;

    picker.recipients = [NSArray arrayWithObject:@"48151623"];  
    picker.body = @"We either live together... or die alone.";

    [self presentModalViewController:picker animated:YES];
    [picker release];