通过 MFMailComposeViewController
发送邮件非常简单。
你无需担心 MFMailComposeViewControllerDelegate
,可以编写代码块。
pod 'EasyMailSender'
MFMailComposeViewController
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];
}
git checkout -b my-new-feature
git commit -am 'Add some feature'
git push origin my-new-feature
MIT