I'm trying to send a email message in my app. I'm trying to use the MFMailComposeViewController object, but getting a error message saying its a "undeclared identifier"
code:
-(IBAction) aContact: (id) sender;
{
if([MFMailComposeViewController canSendMail]){
MFMailComposeViewController *mailCtrl = [[[MFMailComposeViewController alloc] init] autorelease];
[mailCtrl setSubject:@"Your TellaFortune Card Reading"];
// [mailCtrl setToRecipients:[NSArray arrayWithObject:@"[email protected]"]];
mailCtrl.mailComposeDelegate = self;
NSString *send;
send=[ NSString stringWithFormat: @"%@ %@",content,@"\n \n By www.TellaFortune.com"];
[mailCtrl setMessageBody: send isHTML: false];
[self presentModalViewController:mailCtrl animated:NO];
// [mailCtrl release];
}
else
{
UIAlertView *alert=[[ UIAlertView alloc]
initWithTitle:@"Cannot send email"
message: @"Please check internet connection and email set up"
delegate: self
cancelButtonTitle:@"Ok"
otherButtonTitles: nil];
[alert show];
}
}
Import framework "MessageUI.framework" to your project and in your .h file add
#import <MessageUI/MessageUI.h>
For anyone who is using Swift and seeing this message:
First go to your project settings in Xcode, select Build Phases, then Link Binary with Libraries, and add "MessageUI.framework" to your project.
Then, in the Swift file in which you want to use a MFMailComposeViewController
or implement the MFMailComposeViewControllerDelegate
, add:
import MessageUI
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With