title: Attaching a mp3 file to email directly from app?
body: <p>I am working on an app where, if the user selects a sound, they can email it to themselves from the app.</p>
  
  <p>The attachment part 'appears' to work, however, when I send the email, the recipient has no attachment?</p>
  
  <p>On the iPad/iPhone itself, it looks like it is attaching it when it comes to compose, but it is not working? :/</p>
  
  <p>Here is the code I am using;</p>
  
  <pre><code>- (void)onSend:(id)sender{
  
      int nIndex;
  
      UIButton    *btnSender = (UIButton *)sender;
      NSLog( @"%d", btnSender.tag );
  
      for ( int i = 0; i &lt; [ m_aryFileName count ]; i++ ) {
  
          if( i == ( btnSender.tag - 100 ) ){
              nIndex = i;
          }
  
      }
  
      NSString *strFileName = [ m_aryFileName objectAtIndex:nIndex ];
      strFileName = [ strFileName stringByAppendingString:@".mp3" ];
      NSData*     nData = [ NSData dataWithContentsOfFile:strFileName ];
  
      MFMailComposeViewController *pickerMail = [[MFMailComposeViewController alloc] init];
      pickerMail.mailComposeDelegate = self;
  
      [pickerMail setSubject:@"myMail Attachment"];
  
      // Attach an image to the email
      [pickerMail addAttachmentData:nData mimeType:@"audio/mp3" fileName:strFileName ];
  
      // Fill out the email body text
      NSString *emailBody = @"Here is your attachment";
  
      [pickerMail setMessageBody:emailBody isHTML:YES];
  
      [self presentModalViewController:pickerMail animated:YES];
      [pickerMail release];
  
  }
  </code></pre>