iphone - How to add a UIImage to an email using MFMailComposerViewController? -


this question has answer here:

i'm using mfmailcomposerviewcontroller send email ios app. mail works except when trying add image. issue image me getting using

i've seen other examples use like: uiimage *emailimage = [uiimage imagenamed:@"myimagename.png"]; add image. image taken database table using [self.photo objectforkey:kphotopicturekey];

     // mail             // email subject             nsstring *emailtitle = @"join. download iphone app";             // email content             nsstring *messagebody = @"http://www..com/";             // address             nsarray *torecipents = [nsarray arraywithobject:@""];               uiimageview *mailimage = [[uiimageview alloc] init];             mailimage.image = [uiimage imagenamed:@"1.png"]; // placeholder image             mailimage.file = [self.photo objectforkey:kphotopicturekey];             [mailimage loadinbackground];   nsstring *messagebody = [nsstring stringwithformat:@"http://www.example.com/<p><b><img src='data:image/png;base64,%@'></b></p>",mailimage.image];               mfmailcomposeviewcontroller *mc = [[mfmailcomposeviewcontroller alloc] init];             mc.mailcomposedelegate = self;             [mc setsubject:emailtitle];             [mc setmessagebody:messagebody ishtml:no];             [mc settorecipients:torecipents];               // present mail view controller on screen             [self presentviewcontroller:mc animated:yes completion:null]; 

use mate. works fine!!

if ([mfmailcomposeviewcontroller cansendmail]) {             mfmailcomposeviewcontroller *picker = [[mfmailcomposeviewcontroller alloc] init];             picker.mailcomposedelegate = self;             [picker setsubject:@"subject of mail!"];             nsdata *mydata = uiimagejpegrepresentation(image_to_send, 0.9);             [picker addattachmentdata:mydata mimetype:@"image/jpg" filename:@"image_name.jpg"];              // fill out email body text             nsstring *emailbody = @"body of mail";             [picker setmessagebody:emailbody ishtml:no];             [self presentviewcontroller:picker animated:yes completion:nil];   } 

Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

python - pip wont install .WHL files -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -