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

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

问题描述

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



DA |无法打开锁文件/tmp/DAAccountsLoading.lock。我们会加载帐户,但可能会发生不良事情



(如果似乎在我开始填写To字段后出现),并且发送消息失败。



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

  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 / mpegfileName:@tmp.mp3];

适用于我的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|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.

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

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天全站免登陆