0

嗨我使用MFMailComposer發送郵件在我的應用程序,我附上一個圖像,並在身體的HTML內容是最後我添加謝謝,問候消息但所有的文本內容,包括謝謝,問候來了一套,然後我的圖像附件,然後從我的iPhone簽名文本發送即將到來。 我想要感謝您,我的iPhone簽名文本發送之前的文本,我怎麼能實現這一目標?MFMailComposer的地方謝謝,附件圖片後的問候

+0

也分享你的代碼。 –

+0

也分享你的問題的屏幕截圖 –

+0

如果你有一個列表顯示當前電子郵件的順序,然後列出所需的電子郵件,這將更容易閱讀。 –

回答

3

我用的NSData + Base64編碼由馬特·加拉格爾轉換圖像爲base64,所以在你的項目中添加:

首先創建emailBody這樣的:

NSMutableString *emailBody = [[NSMutableString alloc] initWithString:@"<html><body>"] ; 

[emailBody appendString:@"<p>Check Attachment</p>"]; 
UIImage *emailImage = [UIImage imageNamed:@"myImageName.png"]; 
//Convert the image into data 
NSData *imageData = [NSData dataWithData:UIImagePNGRepresentation(emailImage)]; 
//Create a base64 string representation of the data using NSData+Base64 
NSString *base64String = [imageData base64EncodedString]; 
//Add the encoded string to the emailBody string 
//Don't forget the "<b>" tags are required, the "<p>" tags are optional 
[emailBody appendString:[NSString stringWithFormat:@"<p><b><img src='data:image/png;base64,%@'></b></p>",base64String]]; 
//You could repeat here with more text or images, otherwise 
[emailBody appendString:[NSString stringWithFormat:@"<p><b>%@</b></p>",yourString]];// yourString after image here 
//close the HTML formatting 
[emailBody appendString:@"</body></html>"]; 

使用這樣

[MFMailDialog setMessageBody:emailBody isHTML:YES]; 

相信去this答案。