Reputation: 54
In my program modify an image at run time and I have to send it by e-mail. Not required to keep in the device. Any suggestions?
I use this but not works because the image is not saved in mi iphone =(
- (void)emailImage{
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
// Set the subject of email
[picker setSubject:@"MI FOTO FINAL"];
// Fill out the email body text
NSString *emailBody = @"Foto final";
// This is not an HTML formatted email
[picker setMessageBody:emailBody isHTML:NO];
NSData *data = UIImagePNGRepresentation(Foto.image);
[picker addAttachmentData:data mimeType:@"image/png" fileName:@"ImagenFinal"];
// [picker addAttachmentData:data mimeType:nil fileName:nil];
// Show email view
[self presentModalViewController:picker animated:YES];
}
Upvotes: 1
Views: 5241
Reputation: 4409
You can try this one. Image to be in:
UIImage *UIImageToSend;
And the code
MFMailComposeViewController *composer = [[MFMailComposeViewController alloc] init];
[composer setMailComposeDelegate:self];
if([MFMailComposeViewController canSendMail]) {
[composer setToRecipients:[NSArray arrayWithObjects:@"[email protected]",nil]];
[composer setSubject:@"A nice subject"];
[composer setMessageBody:@"Hi,\n\nI'm sending you this beautiful photograph." isHTML:NO];
[composer setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
NSData *data = UIImageJPEGRepresentation(UIImageToSend,1);
[composer addAttachmentData:data mimeType:@"image/jpeg" fileName:@"Photograph.jpg"];
[self presentModalViewController:composer animated:YES];
}
Upvotes: 5
Reputation: 8147
You can use the UIImagePNGRepresentation()
function to extract a png-formatted data from your UIImage
.
Upvotes: 2