开发者

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

开发者 https://www.devze.com 2022-12-14 02:14 出处:网络
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:

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];
开发者_JAVA技巧


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消