views:

22

answers:

1

The current solution is i need to save image and then load attachment with file is it possible to load from UIImageView directly? any idea?

A: 

Attachment is set as a NSData object and you can get it from UIImage object directly using one of the following functions:

  • UIImageJPEGRepresentation - for image in JPEG format
  • UIImagePNGRepresentation - for image in PNG format
Vladimir
if i want to load from uiimaveview is it possible? i dont know solution for load uiimageview to uiimage.
RAGOpoR
yes, get an image from imageview and pass it to functions I mention to get image data. SOmething like this: NSData* data = UIImagePNGRepresentation(imageView.image);
Vladimir
thank you Vladimir.
RAGOpoR
[mail addAttachmentData:data mimeType:@"" fileName:@""]; in mimeType and fileName what should i insert to in because i grab from UIImageView i dont know the mimeType and not have filename
RAGOpoR
mimetype - image/png or image/jpeg depending on what format you use. For file name you can set arbitrary name - I suppose user will see it as an attachment name when he receives email
Vladimir
that correct! thanks Vladimir
RAGOpoR