Can't send email with video/audio attachment on iphone!

柔情痞子 提交于 2019-11-27 07:26:02

问题


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

回答1:


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.



来源:https://stackoverflow.com/questions/1921691/cant-send-email-with-video-audio-attachment-on-iphone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!