Skip to content

Instantly share code, notes, and snippets.

@mluton
Created January 9, 2013 18:57
Show Gist options
  • Save mluton/4495817 to your computer and use it in GitHub Desktop.
Save mluton/4495817 to your computer and use it in GitHub Desktop.
iOS: Generate email compose screen pre-populated with system information
if ([MFMailComposeViewController canSendMail]) {
NSString *iosVersion = [[UIDevice currentDevice] systemVersion];
NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
NSString *appVersion = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
MFMailComposeViewController *mailViewController = [[MFMailComposeViewController alloc] init];
mailViewController.mailComposeDelegate = self;
mailViewController.modalPresentationStyle = UIModalPresentationFormSheet;
[mailViewController setToRecipients:@[@"[email protected]"]];
[mailViewController setMessageBody:[NSString stringWithFormat:@"<br/><br/><hr size=1><strong>UTC Chart Information</strong><br/>App Version: %@<br/>iOS Version: %@<hr size=1>", appVersion, iosVersion] isHTML:YES];
[self presentViewController:mailViewController animated:YES completion:nil];
}
else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Unable to Send Mail" message:@"No email accounts have been configured for this device. At least one email account is required to send feedback." delegate:nil cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
[alert show];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment