2010-07-21 67 views
2

我一直在尝试使用MFMailComposer来发送带有加密数据的文本文件。问题是,当电子邮件到达收件箱时,我的附件永远不会显示出来。相反,一行“<br/><br/>”始终存在。我假设是有关的MIME类型和接收邮件服务器不知道如何读取数据,但我无法找出解决方案。在iPhone SDK中使用MFMailComposer附加纯文本文件

任何人都遇到过这个,并有一个解决方案?

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

认为我有一个修复。看到另一个例子后,我在黑暗中拍摄了一个镜头,它似乎工作。对于mimetype,我只是把@“mime”。

我有点厌倦它,所以我将不得不做一些更多的测试,以确保文件总是出来正确的。