【问题标题】:Email issue: want to send email without additional window电子邮件问题:想在没有额外窗口的情况下发送电子邮件
【发布时间】:2012-12-13 06:02:15
【问题描述】:

我想在不显示 MFMailComposeViewController 的情况下发送电子邮件。我只想将电子邮件发送到一些电子邮件序列(因此用户应该只看到我的微调器,而不是带有发送按钮的 MFMailComposeViewController)。

我知道发送电子邮件的唯一方法是:(但这不是我想要的)

-(void)showMessageController:(id)sender
{

    Class mailClass = (NSClassFromString(@"MFMailComposeViewController"));
    if (mailClass != nil)
    {
        // We must always check whether the current device is configured for sending emails
        if ([mailClass canSendMail])
        {
            [self displayComposerSheet];
        }
        else
        {
            [self launchMailAppOnDevice];
        }
    }
    else
    {
        [self launchMailAppOnDevice];
    }
}

// Displays an email composition interface inside the application. Populates all the Mail fields. 
-(void)displayComposerSheet 
{
    MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
    [appDelegate setNavigationBarTextured:YES navigationBar:picker.navigationBar];
    picker.mailComposeDelegate = self;

    [picker setSubject:@"Please, look at my photo!"];

    // Attach an image to the email (mydata - data of the image)
    [picker addAttachmentData:myData mimeType:@"image/png" fileName:@"photo"];

    // Fill out the email body text
    NSString *emailBody = @"Hello!\nPlease, have a look at my photo!";
    [picker setMessageBody:emailBody isHTML:NO];

    [self presentModalViewController:picker animated:YES];
    [picker release];
}




// Launches the Mail application on the device.
-(void)launchMailAppOnDevice
{
//  NSString *recipients = @"mailto:first@example.com?cc=second@example.com,third@example.com&subject=Hello from California!";
    NSString *recipients = @"mailto:subject=Please, look at my photo!";

    NSString *body = @"&body=Hello!\nPlease, have a look at my photo!";

    NSString *email = [NSString stringWithFormat:@"%@%@", recipients, body];
    email = [email stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:email]];
}

如何在没有 MFMailComposeViewController 的附加屏幕的情况下发送电子邮件?

提前谢谢你!

【问题讨论】:

  • 我认为没有这个是不可能的。

标签: iphone email sendmail mfmailcomposeviewcontroller mfmailcomposer


【解决方案1】:

您可以通过 Web 服务来实现。编写一个 Web 服务,将邮件正文和收件人的电子邮件地址、主题等作为参数并从后端发送邮件。

【讨论】:

    【解决方案2】:

    您可以创建PHP script to send email 并可以通过设备传递的To、Message、Subject 调用php 服务调用,

    【讨论】:

      【解决方案3】:

      Apple 没有提供任何 API 可以让您在没有用户交互的情况下发送电子邮件。

      【讨论】:

        猜你喜欢
        • 2011-06-06
        • 2014-08-11
        • 2018-03-05
        • 2018-07-04
        • 1970-01-01
        • 2012-01-06
        • 1970-01-01
        • 1970-01-01
        • 2017-01-28
        相关资源
        最近更新 更多