- (void)test
{
NSURL *url = [NSURL URLWithString:@"mailto://邮箱地址"];
[[UIApplication sharedApplication] openURL:url];
}
- (void)sendMail
{
MFMailComposeViewController *vc = [[MFMailComposeViewController alloc] init];
//设置主题
[vc setSubject:@"联系作者"];
//设置邮件内容
[vc setMessageBody:@"请说出您对软件的建议" isHTML:YES];
//设置发送人
[vc setToRecipients:@[@"输入邮箱地址"]];
//抄送
//[vc setCcRecipients:@[@""]];
//密送
//[vc setBccRecipients:@[@""]];
vc.mailComposeDelegate = self;
[self presentViewController:vc animated:YES completion:nil];
}
- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
//关闭邮件界面
[controller dismissViewControllerAnimated:YES completion:nil];
}
#pragma mark – 发送按钮
- (IBAction)sendBtn {
[self sendMail];
}
iOS发送邮件功能
最新推荐文章于 2017-06-01 17:26:05 发布