I have a multiple file to attach inside the picker view. When user select that picker view item, they can click email button to attach the chosen file. How do I do so in my picker view?
Here is my sample code.
M File :
-(void)pickerViewEmail:(UIPickerView *)pickerViewEmail didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
if ([[musicList objectAtIndex:row] isEqual:@"m1"])
{
MFMailComposeViewController *pickerEmail = [[MFMailComposeViewController alloc] init];
pickerEmail.mailComposeDelegate = self;
NSString *path = [[NSBundle mainBundle] pathForResource:@"m1" ofType:@"mp3"];
NSData *myData = [NSData dataWithContentsOfFile:path];
[pickerEmail addAttachmentData:myData mimeType:@"audio/mp3" fileName:@"m1"];
[pickerEmail setSubject:@"Hello!"];
// Set up recipients
NSArray *toRecipients = [NSArray arrayWithObject:@"first@example.com"];
NSArray *ccRecipients = [NSArray arrayWithObjects:@"second@example.com", @"third@example.com", nil];
NSArray *bccRecipients = [NSArray arrayWithObject:@"fourth@example.com"];
[pickerEmail setToRecipients:toRecipients];
[pickerEmail setCcRecipients:ccRecipients];
[pickerEmail setBccRecipients:bccRecipients];
// Fill out the email body text
NSString *emailBody = @"Hello";
[pickerEmail setMessageBody:emailBody isHTML:NO];
[self presentModalViewController:pickerEmail animated:YES];
[pickerEmail release];
}
Email Button: How do i start from here.
-(IBAction)showEmail
{
if ([MFMailComposeViewController canSendMail])
{
[self pickerEmail]; I have a yellow error when i call this. What is the right solution?
}
else
{
}
}