2009-11-01 210 views
1

我正在使用MFMailComposeViewController發送文件。一切工作正常15MB以下的文件。任何結束,該文件根本不會附加到MFMailComposeViewController視圖。這並不是說電子郵件服務器不接受,而是它永遠不會被附加在首位。MFMailComposeViewController附件文件大小限制

有沒有人有任何想法,如果有辦法解決這個問題?

我知道很多電子郵件服務無法處理附件超過5或10MB,但其他服務讓您更大的文件大小。

 
MFMailComposeViewController *mail = [[[MFMailComposeViewController alloc] init] autorelease]; 
mail.mailComposeDelegate = self; 
NSString* path = [NSString stringWithFormat:@"%@/%@/%@", NSHomeDirectory(), @"Documents", fileName]; 
NSData *data = [NSData dataWithContentsOfMappedFile:path]; //also tried dataWithContentsOfFile with same results 
[mail addAttachmentData:data mimeType:@"audio/x-caf" fileName:[NSString stringWithFormat:@"%@.caf", label]]; 
[appDelegate.tabBarController presentModalViewController:mail animated:YES]; 

回答

3

加載15 MB 什麼到RAM上預2009年的iPhone或iPod是要真正把你的進程的可用內存的限制,因此這並不奇怪有一個上限。我不會試圖說服撰寫觀點接受更大的附件;相反,我建議您將文件傳輸到某個外部服務器,並通過電子郵件發送鏈接或從那裏發送郵件。

+4

不應該使用dataWithContentsOfMappedFile的要點是電子郵件可以在沒有實際將整個文件一次讀入內存的情況下發送嗎? – 2009-11-25 06:49:54

+1

這是否可行還取決於系統的郵件假脫機程序是否也能夠並且願意從磁盤脫機;我的猜測是它在RAM中構建了整個MIME消息。 – 2010-04-03 05:21:36