iphone - Base64 HTML embedded images not showing when mailed -
iphone - Base64 HTML embedded images not showing when mailed -
i embedding images have been base64 encoded in html follows:
[html appendformat:@"<html><body><p><b><img src=\"data:image/png;base64,%@\"></b></p></body><html>", base64imagestring]; i create new email follows:
mfmailcomposeviewcontroller *mailvc = [[mfmailcomposeviewcontroller alloc] init]; mailvc.mailcomposedelegate = self; [mailvc setmessagebody:html ishtml:yes]; [self presentmodalviewcontroller:mailvc animated:yes]; the embedded image show in new email before sent, not displayed in email client mail service delivered. think fact image shows in draft shows embedding process successful, dont understand why not show when delivered. looking @ raw html in delivered mail service shows: src="cid:(null)" help appreciated please!
i stumbled same problem , solution rather convoluted. possible embed image in email. problem weird reason base64 encoded image must not contain new lines (super odd! know). i'm guessing using nsdata+base64 matt gallagher? i! category creates multi-line base64 string. code in category is
- (nsstring *)base64encodedstring { size_t outputlength; char *outputbuffer = newbase64encode([self bytes], [self length], true, &outputlength); nsstring *result = [[nsstring alloc] initwithbytes:outputbuffer length:outputlength encoding:nsasciistringencoding]; free(outputbuffer); homecoming result; } by replacing 3rd parameter of newbase64encode false single line base64 string , worked me. ended creating new function (just not break else!) within category.
- (nsstring *)base64encodedstringsingleline { size_t outputlength; char *outputbuffer = newbase64encode([self bytes], [self length], false, &outputlength); nsstring *result = [[nsstring alloc] initwithbytes:outputbuffer length:outputlength encoding:nsasciistringencoding]; free(outputbuffer); homecoming result; } using function encode uiimage's nsdata worked fine. email clients have tested far show embedded image. hope works you!
edit: pointed out in comments, solution partial. image attached info uri in email. however, not email clients display embedded image.
iphone ios ipad
Comments
Post a Comment