我正在尝试将图像附加到从应用程序发送的邮件中 我不知道怎么做,请告诉我这里是我的代码:
NSString * subject = @"Hello";
NSString * address = @"myMail@gmail.com";
NSMutableString *strBody=[[NSMutableString alloc]init];
[strBody setString:_txtName.text];
[strBody appendString:_txtIngredients.text];
[strBody appendString:_txtPreper.text];
[strBody appendString:_txtServe.text];
[strBody appendString:_txtAboutdrink.text];
[strBody appendString:_txtSource.text];
//NSData *data = UIImagePNGRepresentation(_imgDrink);---- here is my problem
NSURL *url;
NSString * path = [NSString stringWithFormat:@"mailto:%@?subject=%@&body=%@", address, subject,strBody];
url = [NSURL URLWithString:[path stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
[[UIApplication sharedApplication] openURL:url];
答案 0 :(得分:0)
如果您不介意显示表单以供用户在电子邮件中键入消息,我建议您使用MFMailComposeViewController
。通过它,您可以非常轻松地添加附件。您还可以预先填充收件人和邮件正文以及电子邮件的其他所有内容。这是一个方便的工具包。