开发者

image into mail body in iphone

开发者 https://www.devze.com 2023-02-18 13:50 出处:网络
how to insert uiimage into body of mail composer window.. i have with this code: NSMutableString *emailBody = [[[NSMutableString allocinitWithString:@\"\"] retain];

how to insert uiimage into body of mail composer window.. i have with this code:


NSMutableString *emailBody = [[[NSMutableString allocinitWithString:@""] retain];
[emailBody appendString:@"

type text here

"]; UIImage *emailImage =开发者_如何学Go [UIImage imageNamed:@"20-gear2.png"]; NSData *imageData = [NSData dataWithData:UIImagePNGRepresentation(emailImage)]; NSString *base64String = [imageData base64EncodedString]; [emailBody appendString:[NSString stringWithFormat:@"

",base64String]]; NSLog(@"emailBody....%@", emailBody); [emailBody appendString:@""]; NSLog(@"emailBody1....%@", emailBody);


MFMailComposeViewController *mailComposerController =   [[MFMailComposeViewController alloc] init];
[mailComposerController  setSubject:@"Your subject"];
[mailComposerController setMessageBody:nil isHTML:YES];
NSData *imageData   =   UIImagePNGRepresentation([UIImage imageNamed:"your image.png"]);
[mailComposerController addAttachmentData:imageData mimeType:@"image/png" fileName:@"image.png"];

Hope this help you...


NSData *imageData = UIImagePNGRepresentation(yourImage);
[mailController addAttachmentData:imageData mimeType:@"image/png" fileName:imageName];
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号