I’m trying to implement in-app email for my application and I’m coming across a serious problem. When the button is pushed to open up in-app email, it works just fine. Below are the problems I’m experiencing:
When I hit cancel, it will ask to me save/delete draft of cancel the cancel. If I tap on “Delete Draft” the action sheet goes away but the mail composer stays open. I can interact with it and tap send over and over again and it will keep sending the email. But the cancel button cannot be interacted with anymore. The “Save Draft” button saves the draft of an email, but the composer is still up and I can interact with the cancel button.
Here’s the code I’m using:
- (IBAction)sendEmail:(id)sender {
//Set up of e-mail
sendMail = [[MFMailComposeViewController alloc] init];
sendMail.mailComposeDelegate = self;
//Set the subject
[sendMail setSubject:@"Demo attachment"];
//To recipients
NSArray *toRecepients = [[NSArray alloc] initWithObjects:@"exampleEmail@email.com", @"exampleEmail2@email.com", nil];
[sendMail setToRecipients:toRecepients];
//[sendMail setBccRecipients:toRecepients];
//[sendMail setCcRecipients:toRecepients];
//Add message to the body
NSString *emailBody = @"This is a test email with an attachment.\n";
[sendMail setMessageBody:emailBody isHTML:YES];
//Include an attachment
//NSData *pdfData = [NSData dataWithContentsOfFile:@"demo.pdf"];
//[sendMail addAttachmentData:pdfData mimeType:@"file/pdf" fileName:@"Some file"];
[self presentViewController:sendMail animated:YES completion:NULL];
}
Deploying the app on iOS 6 and using iPhone 5 as a test device. Any help would be appreciated!
Add a
[self dismissModalViewControllerAnimated:YES];to your delegate in the appropriate place.