• ios-->邮件发送


    //
    //  CViewController.m
    //  EmailSendDemo
    //
    //  Created by YTS on 13-8-27.
    //  Copyright (c) 2013年 demo. All rights reserved.
    //

    #import "CViewController.h"

    @interface CViewController ()

    @end

    @implementation CViewController
    @synthesize btnSend = m_btnSend;

    - (void)viewDidLoad
    {
        [super viewDidLoad];
        // Do any additional setup after loading the view, typically from a nib.
    }

    - (void)didReceiveMemoryWarning
    {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
    }

    - (IBAction)send:(id)sender
    {
        NSLog(@"send");
        NSArray *mail = [NSArray arrayWithObjects:@"chendjb@yonyou.com", @"dkl@dlsk.com", nil];
        NSString *subject = @"subject";
        NSString *content = @"to test content";
        [self toSend:mail subject:subject cc:nil bcc:nil content:content];
    }

    - (void)toSend:(NSArray *)mail subject:(NSString *)subject cc:(NSArray *)cc bcc:(NSArray *)bcc content:(NSString *)content
    {
        MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
        if (picker == nil)
        {
            // 不支持Emai或是没有设置Emai账号
            return;
        }
        
        picker.mailComposeDelegate = self;
        
        [picker setSubject:subject];
        [picker setToRecipients:mail];
        
        if (cc != nil)
        {
            [picker setCcRecipients:cc];
        }
        if (bcc != nil)
        {
            [picker setBccRecipients:bcc];
        }
        
        [picker setMessageBody:content isHTML:NO];
        [self presentViewController:picker animated:YES completion:nil];
        [picker release];
    }

    - (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_0);
    {
        NSLog(@"didFinishWithResult");
        [self dismissViewControllerAnimated:YES completion:nil];
    }

    @end

  • 相关阅读:
    缺少环境变量导致Xilinx Platform Studio无法打开之解决方法
    PS利用EMIO控制LED灯
    利用zedboard添加自定义IP核完成简易计算器
    读后感 关于 《不要一辈子靠技术混饭吃》(挪窝第一篇)
    挪窝了,再谈blog
    windows server 2008 无法打开角色,角色错误,刷新服务器时出现意外错误,HRESULT:0x80070422
    Linux 基础正则表达式和扩展正则表达式
    Linux 基础正则表达式
    Linux 通配符与特殊符号
    Linux 基础命令
  • 原文地址:https://www.cnblogs.com/ftrako/p/3285656.html
Copyright © 2020-2023  润新知