2014-01-07 2 views
0

Я записываю аудио и сохраняю его на своем устройстве, и я хочу отправить этот записанный звук в качестве вложения электронной почты. В настоящее время я могу отправить это как почта, но проблема в том, что я загружаю вложение, фактически это файл типа данных, а не файл «.mov». Поэтому я не могу воспроизвести этот загруженный файл.Как я могу отправить файл .mov-рекордера из приложения iOS через почту в виде вложений

Здесь код, используемый для отправки письма.

- (IBAction)submit:(id)sender { 

    if ([MFMailComposeViewController canSendMail]) 
    { 
     MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init]; 

     mailer.mailComposeDelegate = self; 

     [mailer setSubject:@"eGift"]; 

     NSArray *toRecipients = [NSArray arrayWithObjects:@"", nil]; 
     [mailer setToRecipients:toRecipients]; 

//  UIImage *myImage = galleryimage.image; 
     NSData *imageData = [NSData dataWithContentsOfFile:recordFile]; 
    // NSLog(@"%@",imageData); 
     [mailer addAttachmentData:imageData mimeType:@"audio/mov" fileName:@"naveen"]; 


     NSString *emailBody = _smsText.text; 
     [mailer setMessageBody:emailBody isHTML:NO]; 

     // only for iPad 
     // mailer.modalPresentationStyle = UIModalPresentationPageSheet; 

     [self presentModalViewController:mailer animated:YES]; 

     //   } else { 
     //    NSLog(@"Error in resultblock in PhotoAlbumViewController!"); 
     //   } 
     //  }; 



     //[mailer release]; 
    } 
    else 
    { 
     UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Failure" 
                 message:@"Your device doesn't support the composer sheet" 
                 delegate:nil 
               cancelButtonTitle:@"OK" 
               otherButtonTitles: nil]; 
     [alert show]; 
     // [alert release]; 
    } 

} 



#pragma mark - MFMailComposeController delegate 


- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error 
{ 
    switch (result) 
    { 
     case MFMailComposeResultCancelled: 
      NSLog(@"Mail cancelled: you cancelled the operation and no email message was queued"); 
      break; 
     case MFMailComposeResultSaved: 
      NSLog(@"Mail saved: you saved the email message in the Drafts folder"); 
      break; 
     case MFMailComposeResultSent: 
      NSLog(@"Mail send: the email message is queued in the outbox. It is ready to send the next time the user connects to email"); 
      break; 
     case MFMailComposeResultFailed: 
      NSLog(@"Mail failed: the email message was nog saved or queued, possibly due to an error"); 
      break; 
     default: 
      NSLog(@"Mail not sent"); 
      break; 
    } 

    [self dismissModalViewControllerAnimated:YES]; 
} 

ответ

0

Вы просто отсутствует суффикс к типу файла ... (т.е. .mov в вашем имени файла:. Ниже).

сделал быстрое обновление к коду

[mailer addAttachmentData:imageData mimeType:@"audio/mov" fileName:[recordFile lastPathComponent]]; 

Работы для меня теперь и открывает ж/QuickTime.

Смежные вопросы