2010-07-21 36 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」。

我有點厭倦它,所以我將不得不做一些更多的測試,以確保文件總是出來正確的。