Created
March 11, 2015 12:14
-
-
Save funkydevil/a394930def3b77e02396 to your computer and use it in GitHub Desktop.
show mail composer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(void)showMailComposer | |
{ | |
if ([MFMailComposeViewController canSendMail]) | |
{ | |
MFMailComposeViewController *mailComposeViewController = [[MFMailComposeViewController alloc] init]; | |
mailComposeViewController.mailComposeDelegate = self; | |
[mailComposeViewController setSubject:@"My subject"]; | |
[mailComposeViewController setMessageBody:@"Please check log file in attachment" isHTML:NO]; | |
NSData *dataToSend = [Logger logFileData]; | |
[mailComposeViewController addAttachmentData:dataToSend mimeType:@"text/plain" fileName:@"logger.txt"]; | |
[self.navigationController presentViewController:mailComposeViewController animated:YES completion:nil]; | |
} | |
else | |
{ | |
[[[UIAlertView alloc] initWithTitle:@"Cant send log" | |
message:@"Sorry, there is no email accounts on this device." | |
delegate:nil | |
cancelButtonTitle:@"Ok" | |
otherButtonTitles:nil] show]; | |
} | |
} | |
- (void)mailComposeController:(MFMailComposeViewController*)controller | |
didFinishWithResult:(MFMailComposeResult)result | |
error:(NSError*)error; | |
{ | |
if (result == MFMailComposeResultSent) | |
{ | |
NSLog(@"It's away!"); | |
[Logger clearLogFile]; | |
} | |
[self.navigationController dismissViewControllerAnimated:YES completion:nil]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment