iOS自带邮件发送 (邮件分享)

1、首先倒入系统框架       MessageUI.framework

2、导入包            #import <MessageUI/MessageUI.h>

3、实现协议        MFMailComposeViewControllerDelegate

//设置事件即可发送邮件

- (void)SendMail{
  //设置默认的发送信息 /可不设置(灰色表示可不设置的)


    // 邮件主题
    NSString *emailTitle = @"Test Email";


    // 邮件内容
    NSString *messageBody = @"<h1>Learning iOS Programming!</h1>"; // Change the message body to HTML


    // 收件人
    NSArray *toRecipents = [NSArray arrayWithObject:@"support@appcoda.com"];


    MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init];


    mc.mailComposeDelegate = self;


    [mc setSubject:emailTitle];


    [mc setMessageBody:messageBody isHTML:YES]; [mc setToRecipients:toRecipents];


    // 跳转至发送邮件的页面
    [self presentViewController:mc animated:YES completion:NULL];


}

posted on 2013-05-30 12:45  LanSkill  阅读(257)  评论(0编辑  收藏  举报

导航