我正在使用此代码,但它不会发送包含视频的邮件 这是我的代码:
MFMailComposeViewController* controller = [[MFMailComposeViewController alloc] init];
controller.mailComposeDelegate = self;
[controller setSubject:@"My Subject"];
[controller setMessageBody:@"" isHTML:NO]; if (controller) [self presentModalViewController:controller animated:YES];
[controller release];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *dataPath = [documentsDirectory stringByAppendingPathComponent:titleString];
NSLog(@"datapath=%@",dataPath);
NSURL *url=[[NSURL alloc] initFileURLWithPath:dataPath];
NSLog(@"url..%@",url);
NSData *data=[[NSData alloc]initWithContentsOfURL:url ];
[controller addAttachmentData:data mimeType:@"video/quicktime" fileName:titleString];
plzz帮帮我
答案 0 :(得分:1)
这是代码
-(void)displayComposerSheet
{
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[picker setSubject:@"Subject Name"];
// Set up recipients
NSArray *toRecipients = [NSArray arrayWithObject:emailsenderaddress];
NSArray *ccRecipients = [NSArray arrayWithObjects:@"", @"", nil];
NSArray *bccRecipients = [NSArray arrayWithObject:@""];
[picker setToRecipients:toRecipients];
[picker setCcRecipients:ccRecipients];
[picker setBccRecipients:bccRecipients];
// Attach an file to the email
// Fill out the email body text
NSString *emailBody = [NSString stringWithFormat:@""];
[picker setMessageBody:emailBody isHTML:NO];
NSArray *documentPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *saveDirectory = [documentPath objectAtIndex:0];
NSString *saveFileName = [NSString stringWithFormat:@"fileNmae%@.m4v",[invoiceidarray objectAtIndex:OptionView.tag]];
NSString *finalPath = [saveDirectory stringByAppendingPathComponent:saveFileName];
NSData *pdfData = [NSData dataWithContentsOfFile:finalPath];
[picker addAttachmentData:pdfData mimeType:@"application/m4v" fileName:saveFileName];
[self presentModalViewController:picker animated:YES];
[picker release];
}