Email.h
#import <MessageUI/MessageUI.h>
- (IBAction)emailButtonPressed:(id)sender;
Email.m
- (IBAction)emailButtonPressed:(id)sender
{
MFMailComposeViewController *mailController = [[MFMailComposeViewController alloc] init];
[[mailController navigationBar] setTintColor:[UIColor blackColor]];
mailController.mailComposeDelegate = self;
[mailController setSubject:@"Test Email"];
[mailController setToRecipients:[NSArray arrayWithObjects:@"cp@live.com", nil]];
[mailController setMessageBody:@"Test Message" isHTML:NO];
[self presentViewController:mailController animated:YES completion:nil];
}
- (void) mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
[self becomeFirstResponder];
[self dismissViewControllerAnimated:YES completion:nil];
if(result == MFMailComposeResultSent)
{
[[[UIAlertView alloc] initWithTitle:@"Success!"
message:@"Email has been sent successfully." delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil] show];
}
}
No comments:
Post a Comment
Comment