gpt4 book ai didi

iphone - 如何在电子邮件正文中的某些文本之后设置第一个图像?

转载 作者:行者123 更新时间:2023-12-03 20:28:07 25 4
gpt4 key购买 nike

我正在使用 MFMailComposeViewController 发送电子邮件,

使用此代码我可以获得图像,但图像位于文本详细信息之后,我不需要第一个图像和之后的文本,

这是我的代码,

   MFMailComposeViewController *mail = [[MFMailComposeViewController alloc] init];
mail.mailComposeDelegate = self;

if ([MFMailComposeViewController canSendMail]) {
//Setting up the Subject, recipients, and message body.
[mail setToRecipients:[NSArray arrayWithObjects:Emailid,nil]];
[mail setSubject:@"Receipt"];

NSData *photoData = UIImageJPEGRepresentation([UIImage imageNamed:@"Gift.png"], 1);
[mail addAttachmentData:photoData mimeType:@"image/jpg" fileName:[NSString stringWithFormat:@"photo.png"]];

[mail setMessageBody:@"Receipt" isHTML:NO];
NSString *emailBody;




emailBody = [NSString stringWithFormat:@
"<br>Purchase Amount: </br> " "$ %@"
"<br>Amount Received: </br> " "$ %@"
"<br>Change: </br> " "$ %@"
,AmountData,txtAmount.text,ChangeAmount.text];


[mail setMessageBody:emailBody isHTML:YES];

请有人建议我我该怎么做?

最佳答案

据我所知,这是 mfmailcomposeviewcontroller 的默认行为,而不是仅仅将图像添加为附件,您可以按如下方式首先显示图像以创建正文部分

(void)createEmail {


NSMutableString *emailBody = [[[NSMutableString alloc] initWithString:@"<html><body>"] retain];
[emailBody appendString:@"<p>Some email body text can go here</p>"];
UIImage *emailImage = [UIImage imageNamed:@"myImageName.png"];
NSData *imageData = [NSData dataWithData:UIImagePNGRepresentation(emailImage)];

NSString *base64String = [imageData base64EncodedString];
[emailBody appendString:[NSString stringWithFormat:@"<p><b><img src='data:image/png;base64,%@'></b></p>",base64String]];
[emailBody appendString:@"</body></html>"];
NSLog(@"%@",emailBody);

//mail composer window
MFMailComposeViewController *emailDialog = [[MFMailComposeViewController alloc] init];
emailDialog.mailComposeDelegate = self;
[emailDialog setSubject:@"My Inline Image Document"];
[emailDialog setMessageBody:emailBody isHTML:YES];

[self presentModalViewController:emailDialog animated:YES];
[emailDialog release];
[emailBody release];
}

这显示了here

关于iphone - 如何在电子邮件正文中的某些文本之后设置第一个图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10069158/

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