Skip to content

Instantly share code, notes, and snippets.

@xandrucea
Created August 12, 2013 15:00
Show Gist options
  • Save xandrucea/6211586 to your computer and use it in GitHub Desktop.
Save xandrucea/6211586 to your computer and use it in GitHub Desktop.
Send email
----------
- (IBAction)btFeedback:(id)sender {
if ([MFMailComposeViewController canSendMail]) {
NSString *infoString =
[NSString stringWithFormat:@"\n\nUserid: %@ \nUsername: %@ \nIsPush enabled: %@",
_userId,
_userName,
[[NSUserDefaults standardUserDefaults] objectForKey:@"deviceToken" ]];
MFMailComposeViewController* viewController = [[MFMailComposeViewController alloc] init];
viewController.mailComposeDelegate = (id)self;
[viewController setSubject:@"Subject"];
[viewController setMessageBody:infoString isHTML:NO];
[viewController setToRecipients:[NSArray arrayWithObject:@"[email protected]"]];
[_actualView presentViewController:viewController animated:YES completion:nil];
}
}
- inserting delegate method
- (void) mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
switch (result)
{
case MFMailComposeResultCancelled:
NSLog(@"Mail cancelled");
break;
case MFMailComposeResultSaved:
NSLog(@"Mail saved");
break;
case MFMailComposeResultSent:
NSLog(@"Mail sent");
break;
case MFMailComposeResultFailed:
NSLog(@"Mail sent failure: %@", [error localizedDescription]);
break;
default:
break;
}
// Close the Mail Interface
[_actualView dismissViewControllerAnimated:YES completion:NULL];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment