2013-02-13 128 views
2

我使用這個link我的代碼在電子郵件正文部分文本發送圖像下面如何在電子郵件正文中發送圖片?

NSString *urlString = @"url"; 
NSString *searchingurl = [NSString stringWithFormat:@"%@%@", urlString,idnumber]; 
NSString *string = [NSString stringWithFormat:@"%@<br><br>Item No :%@<br>Type :%@<br>Size : %@",searchingurl,str123,mytype,itemsize]; 
NSMutableString *emailBody = [[[NSMutableString alloc] initWithString:@"<html><body>"] retain]; 
NSData *imageData = UIImageJPEGRepresentation(myImage, 1.0f); 
NSString *encodedString = [imageData base64Encoding]; 
[emailBody appendString:[NSString stringWithFormat:@"<p><b><img src='data:image/png;base64,%@'></b></p>",encodedString]]; 
[emailBody appendString:string]; 
[emailBody appendString:@"</body></html>"]; 
NSLog(@"%@",emailBody); 
MFMailComposeViewController *emailDialog = [[MFMailComposeViewController alloc] init]; 
emailDialog.mailComposeDelegate = self; 
[emailDialog setSubject:@""]; 
[emailDialog setMessageBody:emailBody isHTML:YES]; 
[self presentModalViewController:emailDialog animated:YES]; 
[emailDialog release]; 
[emailBody release]; 

Screenshow給出了上面的代碼

enter image description here

發送郵件到雅虎它顯示我的映像後,在Mackbook和iPhone設備上的文本,當我發送郵件到Gmail並在iphone設備中檢查它顯示圖像的文本,但當我在Mackbook中檢查Gmail時它不顯示我的圖像

有人可以指導我,爲什麼我的形象不是顯示在Gmail上PC.Any幫助將appriated.Thanks

+0

可能重複:// stackoverflow.com/questions/12210571/how-to-add-a-image-in-email-body-using-mfmailcomposeviewcontroller) – danh 2013-02-13 17:50:10

+0

@danh但我有不同的情況下你的鏈接顯示文字之前的圖像,但我希望在電子郵件中的文字之前的圖像。 – jamil 2013-02-13 17:54:28

+0

你不能只交換你添加的順序,並添加文本與MIME類型的應用程序/文本 – danh 2013-02-13 18:03:43

回答

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

    [picker setSubject:@"Your subject"]; 


    // Set up recipients 
    NSArray *toRecipients = [NSArray arrayWithObject:@""]; 
    //NSArray *ccRecipients = [NSArray arrayWithObjects:@"[email protected]", @"[email protected]", nil]; 
    //NSArray *bccRecipients = [NSArray arrayWithObject:@"[email protected]"]; 

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


    NSLog(@"Video size >> %d",(videodta.length/1024)/1024); 
    [picker addAttachmentData:imageData mimeType:@"image/png" fileName:@"testapp"]; 

    // Fill out the email body text 
    NSString *emailBody = @"Type your message here"; 
    [picker setMessageBody:emailBody isHTML:NO]; 

    [self presentModalViewController:picker animated:YES]; 
    } 
的(HTTP [如何使用MFMailComposeViewController電子郵件正文中添加圖像]
+0

是的,我知道這種方法,但我在圖像下方顯示一些文本,所以這就是爲什麼這種方法不適合我。 – jamil 2013-02-13 17:42:10

+0

您可以根據您的要求更改名稱.. – Rajneesh071 2013-02-21 08:43:15

+0

您不能添加多個文本..只有名稱 – Rajneesh071 2013-02-21 08:43:39

相關問題