MFMailComposeViewController 附件文件大小限制

发布于 2024-08-09 20:05:55 字数 772 浏览 8 评论 0原文

我正在使用 MFMailComposeViewController 发送文件。对于 15mb 以下的文件,一切正常。一切都结束了,文件根本就不会附加到 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];

I'm using MFMailComposeViewController to send a file. Everything works fine with files under 15mb. Anything over, and the file simply doesn't get attached to the MFMailComposeViewController view. It's not that the email server isn't accepting, its that it never gets attached in the first place.

Does anyone have any ideas if there's a way to resolve that?

I know many email services can't handle attachments over 5 or 10mb, but other services allow you much larger file size.

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];

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

泪是无色的血 2024-08-16 20:05:55

在 2009 年之前的 iPhone 或 iPod 上将 15 MB 的任何内容加载到 RAM 中都会真正突破进程可用内存的限制,因此存在上限也就不足为奇了。我不会试图说服撰写视图接受更大的附件;相反,我建议您将文件传输到某个外部服务器,然后通过电子邮件发送指向该文件的链接或从那里发送邮件。

Loading a 15 MB anything into RAM on a pre-2009 iPhone or iPod is going to really push the limits of your process's available memory, so it's not surprising there's a cap. I wouldn't try to convince the compose view to accept a larger attachment; instead, I'd suggest you transfer the file to some external server and either e-mail a link to it or send the mail from there.

ㄖ落Θ余辉 2024-08-16 20:05:55

目前它有 21mb 限制(与 iOS 15 相关)。但当按下“尝试”按钮时,我至少可以发送 24mb。无法附加 25mb,MFMailComposeViewController 已被系统完全关闭。

输入图片此处描述

Currently it has a 21mb limit (relevant to iOS 15). But I could sent at least 24mb when pressed Try. 25mb couldn't be attached and MFMailComposeViewController was closed by system at all.

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文