-4

iOSで、メールコンポーザを使って、メールの本文(添付ファイルではなく)に画像やテキストを埋め込んだメールを送信したい。誰でも助けることができますか?

4

2 に答える 2

3

これを行うには、img タグを含む HTML コンテンツを使用できます。次のコードを使用できます。

NSMutableString *imgContent = [[[NSMutableString alloc] initWithString:@"<html><body>"] retain];
UIImage *imageData = [UIImage imageNamed:@"Midhun.png"];
NSData *imageDataInBase64 = [NSData dataWithData:UIImagePNGRepresentation(imageData)];
NSString *base64String = [imageDataInBase64 base64EncodedString];
[imgContent appendString:[NSString stringWithFormat:@"<p><b><img src='data:image/png;base64,%@'></b></p>",base64String]];
[imgContent appendString:@"</body></html>"];

 MFMailComposeViewController *emailWin = [[MFMailComposeViewController alloc] init];
[emailWin setMessageBody:imgContent isHTML:YES];
于 2013-04-02T14:15:40.090 に答える
2

MFMailComposeViewController *mailComposer = [[MFMailComposeViewController alloc] init];

[mailComposer setMailComposeDelegate:self];

if ([MFMailComposeViewController canSendMail]) {

    [mailComposer setToRecipients:[NSArray arrayWithObjects:@"kmlshyadav6@gmail.com", nil]];
    [mailComposer setSubject:@"Awesome Image(ur message or subject)"];
    [mailComposer setMessageBody:@"Hey,\n\nCheck out this awesome image!\n\n" isHTML:NO];
    [mailComposer setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];


        UIImage *lion = imageView.image;
        NSData *lionData = UIImageJPEGRepresentation(lion, 1);
        [mailComposer addAttachmentData:lionData mimeType:@"image/jpeg" fileName:@"01-Mac-OS-X-Lion.jpg"];



 }
    [self presentModalViewController:mailComposer animated:YES]; [mailComposer release];
} else {
    [mailComposer release];
}
于 2013-04-02T14:16:41.177 に答える