2013-04-02 61 views

回答

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]; 
+0

謝謝Mithun議員。使用此代碼,圖像顯示在郵件編輯器的正文中,但是一旦我們發送該郵件,它就不會在Windows郵件中收到。它的確反映在Iphone/Ipad中。 –

2

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

[mailComposer setMailComposeDelegate:self]; 

if ([MFMailComposeViewController canSendMail]) { 

    [mailComposer setToRecipients:[NSArray arrayWithObjects:@"[email protected]", 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]; 
} 
+0

感謝Kamalesh,用這種方法,圖片越來越受歡迎,並不反映在郵件的正文中。 –

+0

我們正在使用此代碼,但圖像顯示在郵件編輯器的正文中,但是一旦我們發送該郵件,它就不會在Windows郵件中收到。它確實得到了Iphone/Ipad的反映。請給我建議。 –

相關問題