所以我知道我必须使用MFMailComposeResultSent。 (至少我认为这是我应该使用的)这是我拥有的代码,它发送电子邮件,一切都很好,但邮件编写器保持不变。
编辑:这是我的代码
if ([condition isEqual: @"Excellent"] && [MFMailComposeViewController canSendMail]) {
NSString *emailBody = [NSString stringWithFormat:@"Product:%@ Make:%@ Year Manufactured:%@ Description:%@ Condition:Excellent Email:%@",inputProduct,inputMake,inputYear,inputDescript, inputEmail];
NSArray *recipient = [NSArray arrayWithObject:@"LoveShackElectronics@gmail.com"];
MFMailComposeViewController *SuperLovedEmail = [[MFMailComposeViewController alloc]init];
[SuperLovedEmail setTitle:emailTitle];
[SuperLovedEmail setToRecipients:recipient];
[SuperLovedEmail setMessageBody:emailBody isHTML:NO];
[SuperLovedEmail setUserActivity:false];
[self presentViewController:SuperLovedEmail animated:YES completion:nil];
}
else {
UIAlertController *emailAlert = [UIAlertController alertControllerWithTitle:@"Oh No!" message:@"Your Phone is not able to send an email currently or you have not chosen a condition. Please make sure you have chosen a condition and that you are signed in through Mail" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *emailAlertAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * emailAlertAction) {}];
[emailAlert addAction:emailAlertAction];
[self presentViewController:emailAlert animated:YES completion:nil];
}
答案 0 :(得分:1)
您需要将mailComposeDelegate
对象的SuperLovedEmail
属性设置为self
,然后处理didFinishWithResult
消息,如下所示:
- (void) mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error {
[controller dismissViewControllerAnimated:true completion:nil];
}
您可能会发现评估MFMailComposeResult
以查看实际发送是否有用。