title: Objective C: Take A Photo and Attach in EMail
body: <p>I am trying to make an app that uses the camera of the device to take a photo then attach it to email. I tried to code it but the image don't attach. What I am doing is after taking a photo it will be viewed first on a <code>UIImageView</code>then , clicking the "Done" button will save the image to sandbox and retrieve it for attachment.</p>
  
  <p>Here's my code:
  For saving the image...</p>
  
  <pre><code>NSData *imgData = UIImageJPEGRepresentation(attachingImage, 1);
  jpgPath = [NSHomeDirectory() stringByAppendingPathComponent:@"defectImg.jpg"];
  [imgData writeToFile:jpgPath atomically:YES];
  </code></pre>
  
  <p>For Attachment...</p>
  
  <pre><code>    UIImage *myImage = [UIImage imageNamed:jpgPath];
      NSData *myImageData = UIImagePNGRepresentation(myImage);
      [tempMailCompose addAttachmentData:myImageData mimeType:@"image/jpeg" fileName:@"defectImage.jpg"];
  </code></pre>
  
  <p>What could be wrong?</p>