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

时间:2010-07-21 02:32:25

标签: iphone mfmailcomposeviewcontroller

我一直在尝试使用MFMailComposer发送带有加密数据的文本文件。问题是当电子邮件到达收件箱时,我的附件从不显示。相反,始终存在一行“<br/><br/>”。我假设与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];
  }

感谢您提供任何帮助!

1 个答案:

答案 0 :(得分:1)