Easy to send e-mail by MFMailComposeViewController
.
You don't worry about MFMailComposeViewControllerDelegate
, can write with block.
pod 'EasyMailSender'
- Setup
MFMailComposeViewController
- Call
showFromViewController:
- (IBAction)handleMailButton:(id) sender {
NSString *attachedText = @"text";
EasyMailAlertSender *mailSender = [EasyMailAlertSender easyMail:^(MFMailComposeViewController *controller) {
// Setup
[controller addAttachmentData:[attachedText dataUsingEncoding:NSUTF8StringEncoding] mimeType:@"plain/text" fileName:@"test.txt"];
} complete:^(MFMailComposeViewController *controller, MFMailComposeResult result, NSError *error) {
// When Sent/Cancel - MFMailComposeViewControllerDelegate action
[controller dismissViewControllerAnimated:YES completion:nil];
}];
[mailSender showFromViewController:self];
}
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
MIT