库:
MessageUI.framework
头文件:
MessageUI/MFMailComposeViewController.h
具体代码:
MFMailComposeViewController* mail = [[MFMailComposeViewController
alloc]
init];
mail.mailComposeDelegate =
self;
NSArray *toAdd = [NSArray
arrayWithObject:@"xxxx@163.com"];
NSArray* ccAdd = [NSArray
arrayWithObject:@"xxxx@163.com"];
[mail setToRecipients:toAdd];
[mail setCcRecipients:ccAdd];
[mail setSubject:@"意见反馈", ];
[mail setMessageBody:@"请将您对我公司软件的使用状况填写在下方,谢谢反馈!" isHTML:NO];
if (mail) [self
presentModalViewController:mail animated:YES];
//代理方法
- (void)mailComposeController:(MFMailComposeViewController*)controller
didFinishWithResult:(MFMailComposeResult)result
error:(NSError*)error
{
switch (result)
{
case
MFMailComposeResultCancelled:
{
UIAlertView *alert = [[UIAlertView
alloc] initWithTitle:NSLocalizedString(@"邮件发送取消",
nil)
message:@""
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}
break;
case
MFMailComposeResultSaved:
{
UIAlertView *alert = [[UIAlertView
alloc] initWithTitle:
NSLocalizedString(@"邮件保存成功",
nil)
message:@""
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}
break;
case
MFMailComposeResultSent:
{
UIAlertView *alert = [[UIAlertView
alloc] initWithTitle:NSLocalizedString(@"邮件发送成功",
nil)
message:@""
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}
break;
case
MFMailComposeResultFailed:
{
UIAlertView *alert = [[UIAlertView
alloc] initWithTitle:NSLocalizedString(@"邮件发送失败",
nil)
message:@""
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}
break;
default:
break;
}
[self
dismissModalViewControllerAnimated:YES];
}