如何使用 UIBarButtonItem 发送电子邮件

发布于 2024-12-17 04:56:03 字数 455 浏览 3 评论 0原文

可能的重复:
如何使用 UIbarbuttonitem 发送电子邮件而不使用 MFMailComposerViewController < /p>

作为如图所示,该应用程序用于在单击发送按钮时发送邮件。

我发现它没有显示 MFMailComposerViewController。

在此处输入图像描述

这怎么可能?我如何获得此功能?

Possible Duplicate:
how to send email using UIbarbuttonitem without using MFMailComposerViewController

As shown in the image this app used to send mail on send button's click.

I found that it is not showing MFMailComposerViewController.

enter image description here

How can it be possible? How do I get this functionality?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

清欢 2024-12-24 04:56:03

听起来你只需要仔细阅读教程即可。

我通过谷歌找到了这个:

iPhone 3.0 教程系列中的新增内容,第 2 部分:在应用程序电子邮件中,MessageUI

是的,它说“iPhone 3.0”,但相同的概念和代码应该在 iOS 5 中完美运行。

Sounds like you just need to read a tutorial carefully.

I found this via Google:

New In iPhone 3.0 Tutorial Series, Part 2: In App Email, MessageUI

Yes, it says "iPhone 3.0" but the same concepts and code should work perfectly fine in iOS 5.

老娘不死你永远是小三 2024-12-24 04:56:03
- (void)MailButton:(id)sender
{
    if ([MFMailComposeViewController canSendMail]) {
        //atableView.scrollEnabled=YES;
        //[socailNetworkView removeFromSuperview];
    //  self.navigationItem.title = @"Contents";
        MFMailComposeViewController *mailViewController = [[MFMailComposeViewController alloc] init];
        mailViewController.mailComposeDelegate = self;
        [mailViewController setSubject:@""];
        [mailViewController setMessageBody:@"" isHTML:NO];
        NSString *string = [NSString stringWithFormat:@"", nil];


        NSArray *mailArr = [[NSArray alloc] initWithObjects:string,nil];
        [mailViewController setToRecipients:mailArr];
        [self presentModalViewController:mailViewController animated:YES];
        [mailViewController release];

    }

    else {

        NSLog(@"Device is unable to send email in its current state");

    }
}


- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error;

{

    NSLog(@"Mail");
    NSString  *str=@"";
    switch (result) {  
        case MFMailComposeResultCancelled:  
            NSLog(@"Mail send canceled.");  
            str=@"\nMail sending cancelled";
            //msgLabel.text=str;
            //          [msgLabel setFont:[UIFont fontWithName:@"Arial" size:18]];
            //          msgLabel.textColor=[UIColor colorWithRed:(54.0/255.0) green:(2.0/255) blue:(1.0/255) alpha:1.0];

            /* 
             Execute your code for canceled event here ... 
             */  
            break;  
        case MFMailComposeResultSaved:  
            NSLog(@"Mail saved."); 
            str=@"Mail saved";
            /* 
             Execute your code for email saved event here ... 
             */  
            break;  
        case MFMailComposeResultSent:  
            NSLog(@"Mail sent.");  
            str=@"Mail sent";
            /* 
             Execute your code for email sent event here ... 
             */  
            break;  
        case MFMailComposeResultFailed:  
            str=@"Mail not sent";
            NSLog(@"Mail send error: %@.", [error localizedDescription]);  
            /* 
             Execute your code for email send failed event here ... 
             */  
            break;  
        default:  
            break;  
    }
    //alertLabel.text=str;
    //  [viewAlert setBackgroundColor:[UIColor clearColor]];
    //  [self.view addSubview:viewAlert];

    [self dismissModalViewControllerAnimated:YES];
}
- (void)MailButton:(id)sender
{
    if ([MFMailComposeViewController canSendMail]) {
        //atableView.scrollEnabled=YES;
        //[socailNetworkView removeFromSuperview];
    //  self.navigationItem.title = @"Contents";
        MFMailComposeViewController *mailViewController = [[MFMailComposeViewController alloc] init];
        mailViewController.mailComposeDelegate = self;
        [mailViewController setSubject:@""];
        [mailViewController setMessageBody:@"" isHTML:NO];
        NSString *string = [NSString stringWithFormat:@"", nil];


        NSArray *mailArr = [[NSArray alloc] initWithObjects:string,nil];
        [mailViewController setToRecipients:mailArr];
        [self presentModalViewController:mailViewController animated:YES];
        [mailViewController release];

    }

    else {

        NSLog(@"Device is unable to send email in its current state");

    }
}


- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error;

{

    NSLog(@"Mail");
    NSString  *str=@"";
    switch (result) {  
        case MFMailComposeResultCancelled:  
            NSLog(@"Mail send canceled.");  
            str=@"\nMail sending cancelled";
            //msgLabel.text=str;
            //          [msgLabel setFont:[UIFont fontWithName:@"Arial" size:18]];
            //          msgLabel.textColor=[UIColor colorWithRed:(54.0/255.0) green:(2.0/255) blue:(1.0/255) alpha:1.0];

            /* 
             Execute your code for canceled event here ... 
             */  
            break;  
        case MFMailComposeResultSaved:  
            NSLog(@"Mail saved."); 
            str=@"Mail saved";
            /* 
             Execute your code for email saved event here ... 
             */  
            break;  
        case MFMailComposeResultSent:  
            NSLog(@"Mail sent.");  
            str=@"Mail sent";
            /* 
             Execute your code for email sent event here ... 
             */  
            break;  
        case MFMailComposeResultFailed:  
            str=@"Mail not sent";
            NSLog(@"Mail send error: %@.", [error localizedDescription]);  
            /* 
             Execute your code for email send failed event here ... 
             */  
            break;  
        default:  
            break;  
    }
    //alertLabel.text=str;
    //  [viewAlert setBackgroundColor:[UIColor clearColor]];
    //  [self.view addSubview:viewAlert];

    [self dismissModalViewControllerAnimated:YES];
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文