I am using Xcode to create an objective c application
Is there any way to send an email, from a form of five or so text fields, so that when the user clicks the send button, it will send the data they have entered into the text fields to a pre defined email address.
I have tried searching for relevant questions already asked but a lot of the techniques used are deprecated now.
I have tried:
-(IBAction)email {
MFMailComposeViewController *composer = [[MFMailComposeViewController alloc] init];
[composer setMailComposeDelegate:self];
([MFMailComposeViewController canSendMail]); {
[composer setToRecipients:[NSArray arrayWithObjects:@"makingwavesswimschool@live.co.uk", nil]];
[composer setSubject:@"Enter Subject Here"];
[composer setMessageBody:@"Enter Message Here" isHTML:NO];
[composer setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
[self presentModalViewController:composer animated:YES];
}
}
-(void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error {
if (error) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error"
message:[NSString stringWithFormat:@"Error %@", [error description]]
delegate:nil cancelButtonTitle:@"Dismiss" otherButtonTitles:nil, nil];
[alert show];
[self dismissModalViewControllerAnimated:YES];
}
else {
[self dismissModalViewControllerAnimated:YES];
}
}
However this crashes to the present and dismiss modal view controller being deprecated.
Is there a way to modify this to work off of a form?
Thanks