我想通过 iphone 中的电子邮件发送扩展名为 .caf 的音频文件。谁能帮我做到这一点?我已经写mimeType:@"audio/caf"
了,但我认为它不支持这一点。请帮我完成这个小任务。
问问题
1603 次
1 回答
7
使用下面的代码: -
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filepath = [documentsDirectory stringByAppendingPathComponent:memo.memoUrl];
NSURL *fileURL = [[NSURL alloc] initFileURLWithPath:filepath];
NSData *dataToSend = [[NSData alloc] initWithContentsOfURL:fileURL];
[fileURL release];
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[picker setSubject:@"Recording"];
// Set up recipients
NSArray *toRecipients = nil;
NSArray *ccRecipients = nil;
NSArray *bccRecipients = nil;
[picker setToRecipients:toRecipients];
[picker setCcRecipients:ccRecipients];
[picker setBccRecipients:bccRecipients];
[picker setMessageBody:@"" isHTML:YES];
[picker addAttachmentData:dataToSend mimeType:@"audio/x-caf" fileName:[NSString stringWithFormat:@"voice-memo.caf", memo.memoName]];
于 2012-09-06T11:35:39.723 回答