zoukankan      html  css  js  c++  java
  • 调用IOS邮件系统发送邮件

    1.导入MessageUI.framework框架

    2.在需要应用的控制器头文件:#import <MessageUI/MessageUI.h>,并加入委托:<MFMailComposeViewControllerDelegate>

    3.实现方法:

    -(void)displayComposerSheet 
    {
        MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
        picker.mailComposeDelegate = self;
        
        [picker setSubject:@"Enter Your Subject!"];
        
        // Set up recipients
        NSArray *toRecipients = [NSArray arrayWithObject:@"donald.wong5@gmail.com"]; 
         
        
        [picker setToRecipients:toRecipients];
        
        // Attach an image to the email
        NSString *path = [[NSBundle mainBundle] pathForResource:@"" ofType:@"png"];
        NSData *myData = [NSData dataWithContentsOfFile:path];
        [picker addAttachmentData:myData mimeType:@"image/png" fileName:@""];
        
        // Fill out the email body text
             
        [self presentModalViewController:picker animated:YES];
        
    }
    - (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error 
    {    
         
        [self dismissModalViewControllerAnimated:YES];
    }

  • 相关阅读:
    nodejs获取服务器数据到页面
    Struts 2
    JQuery
    JDBC
    Hiberbate
    EasyUi
    JavaScript
    利用 HashSet 去过滤元素是否重复
    HTML
    MySQL
  • 原文地址:https://www.cnblogs.com/hellocby/p/2693680.html
Copyright © 2011-2022 走看看