在iPhone SDK中使用MFMailComposer附加纯文本文件 [英] Attaching plain text file using MFMailComposer in iPhone SDK

查看:90
本文介绍了在iPhone SDK中使用MFMailComposer附加纯文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用MFMailComposer发送包含加密数据的文本文件.问题是当电子邮件到达收件箱时,我的附件永不显示.而是始终显示一行"<br/><br/>".我假设这与mime类型有关,接收者邮件服务器不知道如何读取数据,但我只是想不出解决办法.

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!

推荐答案

我认为已解决.在看到另一个示例之后,我只是在黑暗中开了枪,它似乎奏效了.对于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.

这篇关于在iPhone SDK中使用MFMailComposer附加纯文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆