7

iPad から送信された HTML メールの本文に画像を含めようとしています。無理そうです。CID アプローチを使用しようとしましたが、iOS では添付ファイルの CID を取得/設定できないようです。

で画像を埋め込もうとしましたsrc="data:image/png;base64, blahblahblah"。メールを作成すると動作するように見えますが、メールを受信して​​も何も表示されません。

何か案は?

詳細: メールの末尾に JPEG/PNG を添付するソリューションは求めていません。それは簡単です[composer addAttachmentData:mimeType:fileName:]

画像がHTML 形式のメールにインラインで埋め込まれているソリューションを探しています。その IMG タグの周りにリンクをラップして、受信者が IMG をクリックすると、アプリの iTunes ページにリンクされるようにすることができます。

4

3 に答える 3

6

githubNSData+base64からカテゴリをダウンロードします。

次に、次の操作を行います。

NSData *imageData = [NSData dataWithContentsOfFile:pathInDocumentDirectory(imagePath)];
NSString *base64String = [imageData base64EncodedString];
NSString *imageString = [NSString stringWithFormat:@"data:image/png;base64,%@", base64String];

最後に、imageStringこの画像を表示したい HTML 本文に を挿入します。

それが役に立てば幸い!

于 2012-12-06T10:23:52.613 に答える
1

iphoneのメール添付から

MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;

[picker setSubject:@"Hello"];


// Set up recipients
NSArray *toRecipients = [NSArray arrayWithObject:@"first@example.com"]; 
NSArray *ccRecipients = [NSArray arrayWithObjects:@"second@example.com",           @"third@example.com", nil]; 
NSArray *bccRecipients = [NSArray arrayWithObject:@"fourth@example.com"]; 

[picker setToRecipients:toRecipients];
[picker setCcRecipients:ccRecipients];  
[picker setBccRecipients:bccRecipients];

// Attach an image to the email
NSString *path = [[NSBundle mainBundle] pathForResource:@"rainy" ofType:@"png"];
NSData *myData = [NSData dataWithContentsOfFile:path];
[picker addAttachmentData:myData mimeType:@"image/png" fileName:@"rainy"];

// Fill out the email body text
NSString *emailBody = @"It is raining";
[picker setMessageBody:emailBody isHTML:NO];

[self presentModalViewController:picker animated:YES];
[picker release];  
于 2012-12-05T18:45:12.317 に答える
0

Gmail で画像を表示するには、次のようにします。

MFMailComposeViewController *mailCont = [[MFMailComposeViewController alloc] init];
    mailCont.mailComposeDelegate = self; 

    NSMutableString *emailBody = [[NSMutableString alloc] initWithCapacity:20];

    NSString *linkimg = @"https://idrivethru.com/iDriveThruWeb/faces/javax.faces.resource/idrivethru_logo.png?ln=images";

    //Add the image
    [emailBody appendFormat:@"<p><a href = 'https://idrivethru.com/'> <img src='%@' align='centre' alt='iDriveThru.com'> </a></p><br/>", linkimg];

    [emailBody appendString:@"<p>This is an email with an embeded image right <b>above</b> this text</p>"];

    //NSLog(@"%@",emailBody);

    [mailCont setMessageBody:emailBody isHTML:YES];
    [self presentViewController:mailCont animated:YES completion:nil];
于 2015-12-29T21:50:43.653 に答える