forked from KevinHM/XCode_Snippets_iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhmMailComp.m
More file actions
33 lines (27 loc) · 1.35 KB
/
Copy pathhmMailComp.m
File metadata and controls
33 lines (27 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
---
title: "MFMailComposeViewController Init & Delegate"
summary: "Methods required to use the iOS Mail Composer"
completion-scope: Class Implementation
---
- (void)presentModalMailComposerViewController:(BOOL)animated {
if ([MFMailComposeViewController canSendMail]) {
MFMailComposeViewController *composeViewController = [[MFMailComposeViewController alloc] init];
composeViewController.mailComposeDelegate = self;
[composeViewController setSubject:<#Subject#>];
[composeViewController setMessageBody:<#Body#> isHTML:YES];
[composeViewController setToRecipients:@[<#Recipients#>]];
[self presentViewController:composeViewController animated:animated completion:nil];
} else {
[[[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Error", nil)
message:NSLocalizedString(@"<#Cannot Send Mail Message#>", nil)
delegate:nil cancelButtonTitle:NSLocalizedString(@"OK", nil) otherButtonTitles:nil] show];
}
}
#pragma mark - MFMailComposeViewControllerDelegate
- (void)mailComposeController:(MFMailComposeViewController *)controller
didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error {
if (error) {
NSLog(@"%@", error);
}
[self dismissViewControllerAnimated:YES completion:nil];
}