Search code examples
stringimageios5uiviewxcode4

How do i attach image form ui view to email body


I have a small ui view that alows user to select a pic form camera roll, i want to attach it along with my text fields in email.

.h
 @property (strong, nonatomic) IBOutlet UIImageView *imageView;

 .m
  NSString *emailBody = [NSString stringWithFormat:@(textboxes and other outlets are      here)"%@"imageView.image];

When emailed I get the text strings attached but not the image? Coul dsomeone point me in the right direction on this, thanks

xcode 4.3


Solution

  • try this link to send images by email

    http://iosdevelopertips.com/email/how-to-send-email-with-attachments-example-using-iphone-camera-to-email-a-photo.html

    if that is not what u want u may have to convert image to nsdata using the functions

    NSData *data=UIImageJPEGRepresentation(image, 1.0);
    

    now convert this data to string by base64encoding and then attach to string.