title: How can I send an image with MFMailComposeViewController
body: <p>I am trying to send an email using MFMailComposeViewController but somehow it won't work. When I don't send an image everything works just fine. But if I try to add photo there is the following error:</p>
  
  <pre><code>-(IBAction)gonder:(id)sender{
    MFMailComposeViewController *mailComposeViewController = [[MFMailComposeViewController alloc] init];
    mailComposeViewController.mailComposeDelegate = self;
  
    [mailComposeViewController setSubject:@"deneme"];
    UIImage *savedImage = self.image;
    NSData *imageData = UIImagePNGRepresentation(savedImage);
    [mailComposeViewController addAttachmentData:imageData mimeType:@"image/png" fileName:@"photo"];
    NSString *emailBody = @"my text";
    [mailComposeViewController setMessageBody:emailBody isHTML:NO];
  
    [emailBody release];
    NSArray *alicilar=[[NSArray alloc]initWithObjects:@"mymailadress.com", nil];
    [mailComposeViewController setToRecipients:alicilar];
  
    [mailComposeViewController view];
  }
  
  - (void) mailComposeController:(MFMailComposeViewController*)mailComposeViewController bodyFinishedLoadingWithResult:(NSInteger)result error:(NSError*)error
  {
    @try
    {
      id mailComposeController = [mailComposeViewController valueForKeyPath:@"internal.mailComposeController"];
      id sendButtonItem = [mailComposeViewController valueForKeyPath:@"internal.mailComposeView.sendButtonItem"];
      [mailComposeController performSelector:@selector(send:) withObject:sendButtonItem];
    }
    @catch (NSException *e) {}
    [mailComposeViewController release];
  }
  </code></pre>
  
  <p>Those are the errors:<br>
  <code>2012-02-14 16:19:58.322 il[653:307] *** ERROR: FigCreateCGImageFromJPEG returned -12905. Input (null) was 444585 bytes.</code></p>