我想在我的应用程序上打开本机邮件客户端并发送以下内容:
NSString *subject = [NSString stringWithFormat:@"%@", self.selectedProposal.title];
NSString *mail = [NSString stringWithFormat:@""];
NSData *imageData = [NSData dataWithData:UIImagePNGRepresentation( self.logoImageView.image )];
CreditCalculatorModel *model = [CreditCalculatorModel tlSharedInstance];
NSString *emailBody = @"";
emailBody = [emailBody stringByAppendingString:[NSString stringWithFormat:@"<p><center><img src='data:image/png;base64,%@'></center></p>", [imageData base64EncodedString]]];
emailBody = [emailBody stringByAppendingFormat:@"<p><center><h4>%@</h4></center></p>", self.selectedProposal.title];
emailBody = [emailBody stringByAppendingString:@"<br />"];
emailBody = [emailBody stringByAppendingString:self.amountLabel.text];
emailBody = [emailBody stringByAppendingString:@"<br />"];
emailBody = [emailBody stringByAppendingString:self.initialLabel.text];
emailBody = [emailBody stringByAppendingString:@"<br />"];
emailBody = [emailBody stringByAppendingString:self.creditAmountLabel.text];
emailBody = [emailBody stringByAppendingString:@"<br />"];
emailBody = [emailBody stringByAppendingFormat:@"Процентная ставка: %@", self.rateLabel.text];
emailBody = [emailBody stringByAppendingString:@"<br />"];
emailBody = [emailBody stringByAppendingFormat:@"Эффективная ставка: %@", self.efficientRateLabel.text];
emailBody = [emailBody stringByAppendingString:@"<br />"];
emailBody = [emailBody stringByAppendingFormat:@"Ежемесячный платёж: %@", self.paymentLabel.text];
emailBody = [emailBody stringByAppendingString:@"<br />"];
emailBody = [emailBody stringByAppendingFormat:@"Переплата по кредиту: %@", self.overheadLabel.text];
emailBody = [emailBody stringByAppendingString:@"<br />"];
emailBody = [emailBody stringByAppendingString:@"<br /></h5>График платежей</h5><br />"];
emailBody = [emailBody stringByAppendingString:@"<table border='1'>"];
emailBody = [emailBody stringByAppendingString:@"<tr><td>Месяц</td><td>Задолженность</td><td>Платёж</td></tr>"];
for ( int i = 0; i < model.term; i++ )
{
emailBody = [emailBody stringByAppendingFormat:@"<tr><td>%d</td><td>%@ р.</td><td>%@ р.</td></tr>",
i + 1,
[self.unicomDecimalNumberFormatter stringFromNumber:@((int) [CreditCalculatorModel deptForMonth:i
withRate:[self.selectedProposal.rate doubleValue]/100
andAmount:model.amount
andTerm:model.term
andInitial:model.initial
andAnnuity:!self.selectedProposal.payment_type])],
[self.unicomDecimalNumberFormatter stringFromNumber:@((int) [CreditCalculatorModel paymentForMonth:i
withRate:[self.selectedProposal.rate doubleValue]/100
andAmount:model.amount
andTerm:model.term
andInitial:model.initial
andAnnuity:!self.selectedProposal.payment_type])]
];
}
emailBody = [emailBody stringByAppendingString:@"</table>"];
NSString *recipients = @"mailto:?to=";
NSString *subjectMessage = [NSString stringWithFormat:@"&subject=%@", subject];
NSString *bodyMessage = [NSString stringWithFormat:@"&body=%@", emailBody];
NSString *email = [NSString stringWithFormat:@"%@%@%@", recipients, subjectMessage, bodyMessage];
email = [email stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:email]];
除了图像表示之外,一切都很好。它不显示。在图像的地方只出现一个小的空矩形。图像表示在电话选项中处于打开状态。而且我不能用 MFMailComposeViewController 完成这项任务。谢谢帮助