我正在尝试实现自动填充的电子邮件。我在单独的测试环境中正确弹出了 emailviewcontroller,但我无法弄清楚如何将字符串添加到消息正文中。基本上我在 gui 的根控制器上有三个按钮,用于设置三个字符串的值。我想要的只是在消息正文中重现这三个字符串(如果可能,用逗号分隔)。到目前为止,这是我的代码:
-(IBAction)displayComposerSheet
{
NSArray *recipient = [NSArray arrayWithObjects:@"testemail@office.co.uk", nil];
if([MFMailComposeViewController canSendMail])
{
MFMailComposeViewController *mailViewController = [[MFMailComposeViewController alloc] init];
mailViewController.mailComposeDelegate = self;
[mailViewController setSubject:@"Place holder ... this is a test subject"];
[mailViewController setMessageBody: isHTML:NO];
[mailViewController setToRecipients:recipient];
[self presentModalViewController:mailViewController animated:YES];
}
else
NSLog(@"Device is unable to send email in its current state");
}
-(void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithREsult:(MFMailComposeResult)result error:(NSError *)error
{
[self dismissModalViewControllerAnimated:YES];
}
- (IBAction)addString1:(id)sender {
NSString *string1;
string1 = @"teststring1";
}
- (IBAction)addString2:(id)sender {
NSString *string2;
string2 = @"teststring2";
}
- (IBAction)addString3:(id)sender {
NSString *string3;
string3 = @"teststring3";
}