无法在 iPhone 上发送带有视频/音频附件的电子邮件! [英] Can't send email with video/audio attachment on iphone!

查看:74
本文介绍了无法在 iPhone 上发送带有视频/音频附件的电子邮件!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 MFMailComposeViewController 发送电子邮件.我可以发送附有图像的电子邮件,但是当我尝试附加 mp3 或 mp4 文件时,我收到以下消息:

I am trying to send an email with MFMailComposeViewController. I'm able to send emails with images attached, but when I try to attach mp3 or mp4 files I get this message:

DA|无法打开/tmp/DAAccountsLoading.lock 中的锁定文件.无论如何我们都会加载帐户,但可能会发生不好的事情

DA|Could not open the lock file at /tmp/DAAccountsLoading.lock. We'll load the accounts anyway, but bad things may happen

(如果似乎在我开始填写收件人"字段后立即出现),并且发送消息失败.

(if seems to appear right after I start filling the "To" field), and sending the message fails.

这是我的代码(HelperUtils 类只是我创建的,我确定问题不存在):

Here is my code (The HelperUtils class is just something I created and I'm sure the problem is not there):

NSData *myData = [NSData dataWithContentsOfFile:[HelperUtils getPathWithEnding:media.name]];
NSString *mimeTypeStr = [HelperUtils getMimeTypeOfFileWithPath:[HelperUtils getPathWithEnding:media.name]];
NSLog(mimeTypeStr);
NSLog([HelperUtils getPathWithEnding:media.name]);
[picker addAttachmentData:myData mimeType:mimeTypeStr fileName:media.name];

推荐答案

NSString *mp3File = [NSTemporaryDirectory() stringByAppendingPathComponent: @"tmp.mp3"];
NSURL    *fileURL = [[NSURL alloc] initFileURLWithPath:mp3File];
NSData *soundFile = [[NSData alloc] initWithContentsOfURL:fileURL];
[mailDialogController addAttachmentData:soundFile mimeType:@"audio/mpeg" fileName:@"tmp.mp3"];

适用于 mp3 文件.当你说 mp4 失败时,是什么方式?

works for me with mp3 files. when you say it fails with mp4, in what way?

如果应用程序在几次后崩溃,则您很可能在某处发生了内存泄漏.

if app is crashing after a few, you have a memory leak somewhere most likely.

这篇关于无法在 iPhone 上发送带有视频/音频附件的电子邮件!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆