使用 MFMailComposeViewController 将大纲作为电子邮件发送

发布于 2024-08-05 08:11:02 字数 1383 浏览 8 评论 0原文

我想使用 MFMailComposeViewController 通过电子邮件发送文本大纲。我目前正在通过创建文档的 HTML 版本并将其设置为消息正文来执行此操作。在 MFMailComposeViewController 中查看电子邮件时,这工作正常,但在接收端(MobileMail.app、GMail Webinterface、OSX Mail.应用程序)格式丢失。

这是我当前的代码:

- (IBAction)showMailController {
    if (![MFMailComposeViewController canSendMail]) return;
    MFMailComposeViewController *mailComposeViewController = [[MFMailComposeViewController alloc] init];
mailComposeViewController.mailComposeDelegate = self;

    NSString *stringRepresentation = @"<html><head></head><body><ul><li>@grocery</li><ul><li>Milk</li><li>Cat food</li><li>Rice</li><li>Tofu</li></ul></ul></body></html>";
    [mailComposeViewController setMessageBody:stringRepresentation isHTML:YES];

    [self presentModalViewController:mailComposeViewController animated:YES];
    [mailComposeViewController release];    
}

我做错了什么吗?还有其他方法吗?

我还尝试通过手动缩进导出为简单的文本大纲(我插入了两个空格,因为制表符不起作用),但文本编辑器无法将其识别为大纲。

NSMutableString *inset = [[NSMutableString alloc] init];
NSUInteger i;
for (i=0; i<insetCount;i++) {
    [inset appendString:@"  "];
}


NSMutableString *string = [[NSMutableString alloc] initWithString: [NSString stringWithFormat:@"%@%C ", inset, 0x2022]];

感谢您的帮助!

I'd like to send a text outline via email using MFMailComposeViewController. I'm currently doing this by creating a HTML version of the document and setting this as the body of the message.This works fine when viewing the email in MFMailComposeViewController, but on the receiving end (MobileMail.app, GMail Webinterface, OSX Mail.app) the formatting is lost.

This is my current code:

- (IBAction)showMailController {
    if (![MFMailComposeViewController canSendMail]) return;
    MFMailComposeViewController *mailComposeViewController = [[MFMailComposeViewController alloc] init];
mailComposeViewController.mailComposeDelegate = self;

    NSString *stringRepresentation = @"<html><head></head><body><ul><li>@grocery</li><ul><li>Milk</li><li>Cat food</li><li>Rice</li><li>Tofu</li></ul></ul></body></html>";
    [mailComposeViewController setMessageBody:stringRepresentation isHTML:YES];

    [self presentModalViewController:mailComposeViewController animated:YES];
    [mailComposeViewController release];    
}

Am I doing something wrong? Is there an other way to do it?

I also tried exporting as simple text outline with manually indenting (I inserted two spaces as tab didn't work), but text editors don't recognize this as an outline.

NSMutableString *inset = [[NSMutableString alloc] init];
NSUInteger i;
for (i=0; i<insetCount;i++) {
    [inset appendString:@"  "];
}


NSMutableString *string = [[NSMutableString alloc] initWithString: [NSString stringWithFormat:@"%@%C ", inset, 0x2022]];

Thank you for your help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

旧时浪漫 2024-08-12 08:11:02

在我的应用程序中,我只放置正文标签之间的内容,即没有

html    
head
body

标签。只需将您通常放入正文标签之间的内容即可,它应该可以工作。

In my apps, I only put what is in between the body tags, i.e. NO

html    
head
body

tags. Just put the stuff you would normally put in between the body tags and it should work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文