2012-09-06 70 views

回答

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

是啊..我用過mimetype:@「audio/caf」,我的錯誤是我沒有在文件名後面寫入.caf擴展名..一旦我在文件名後面添加了.caf擴展名,它就開始工作了。方式感謝。 –

相關問題