我正在尝试在我的应用程序中发送电子邮件。我正在尝试使用MFMailComposeViewController对象,但收到一条错误消息,提示其为“未声明的标识符”
代码:
-(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];
}
}
最佳答案
将框架“MessageUI.framework”导入到项目中,然后在.h文件中添加
#import <MessageUI/MessageUI.h>