使用 iPhone SDK 中的 MFMailComposer 附加纯文本文件

发布于 2024-09-11 01:54:42 字数 998 浏览 14 评论 0原文

我一直在尝试使用 MFMailComposer 发送其中包含加密数据的文本文件。问题是当电子邮件到达收件箱时我的附件永远不会显示。相反,一行“
>
>
”始终存在。我假设这与 mime 类型有关,并且接收者邮件服务器不知道如何读取数据,但我只是想不出解决方案。

有人以前遇到过这个问题并有解决方案吗?

if([MFMailComposeViewController canSendMail]) {
   MFMailComposeViewController *mailController = [[MFMailComposeViewController alloc] init];
   mailController.mailComposeDelegate =self;
   [mailController setSubject:@"Records"];
   [mailController setMessageBody:@"" isHTML:YES];
   [mailController addAttachmentData:dataToBeEncrypted mimeType:@"text/plain" fileName:@"Records.txt"];
   [self presentModalViewController:mailController animated:YES];
   [mailController release];
  } else {
  //Pop up a notification
   UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Could not send email. Verify Internet conneciton and try again." delegate:nil cancelButtonTitle:@"Done" otherButtonTitles:nil];
   [alert show];
   [alert release];
  }

感谢您提供的任何帮助!

I've been trying to use MFMailComposer to send a text file with encrypted data within. The problem is my attachment never shows up when when the email arrives in the inbox. Instead, a line of "<br/><br/>" is always present. I'm assuming is has something to do with the mime type and the receivers mail server not know how to read the data but I just can't figure out a solution.

Anyone come across this before and have a solution?

if([MFMailComposeViewController canSendMail]) {
   MFMailComposeViewController *mailController = [[MFMailComposeViewController alloc] init];
   mailController.mailComposeDelegate =self;
   [mailController setSubject:@"Records"];
   [mailController setMessageBody:@"" isHTML:YES];
   [mailController addAttachmentData:dataToBeEncrypted mimeType:@"text/plain" fileName:@"Records.txt"];
   [self presentModalViewController:mailController animated:YES];
   [mailController release];
  } else {
  //Pop up a notification
   UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Could not send email. Verify Internet conneciton and try again." delegate:nil cancelButtonTitle:@"Done" otherButtonTitles:nil];
   [alert show];
   [alert release];
  }

Thanks for any help you can give!

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

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

发布评论

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

评论(1

淡笑忘祈一世凡恋 2024-09-18 01:54:42

我想我已经解决了。在看到另一个例子后,我只是在黑暗中尝试了一下,它似乎有效。对于 mimetype,我只是输入@“mime”。

我对此有点厌倦,所以我必须做更多测试以确保文件始终正确。

Think I got a fix. I just took a shot in the dark after seeing another example and it seemed to work. For mimetype, I just put @"mime".

I'm a little weary of it, so I'll have to do some more testing to make sure the file always comes out correct.

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