gpt4 book ai didi

iphone - MFMailComposer 在附件图片后放置感谢、问候文本

转载 作者:行者123 更新时间:2023-11-28 20:29:55 26 4
gpt4 key购买 nike

您好,我在我的应用程序中使用 MFMailComposer 发送邮件,我在其中附加了一张图片,正文中有 html 内容,最后我在邮件中添加了感谢,问候消息,但所有文本内容包括感谢,问候即将到来,作为一组,然后是我的图像附件,然后是从我的 iPhone 签名文本发送的。我想在从我的 iPhone 签名文本发送之前表示感谢,问候文本,我该如何实现?

最佳答案

我使用了 Matt Gallagher 的 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回答。

关于iphone - MFMailComposer 在附件图片后放置感谢、问候文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12622095/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com