0

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 の追加画面なしでメールを送信するにはどうすればよいですか?

前もって感謝します!

4

3 に答える 3

1

ユーザーの操作なしで電子メールを送信できるようにする API は Apple から提供されていません。

于 2012-12-13T06:14:39.863 に答える
1

電子メールを送信するための PHP スクリプトを作成し、デバイスから渡された To、Message、Subject を使用して PHP サービス呼び出しを呼び出すことができます。

于 2012-12-13T06:07:01.730 に答える
1

Web サービスで実現できます。メール本文と受信者のメールアドレス、件名などのメッセージをパラメーターとして受け取り、バックエンドからメールを送信する Web サービスを作成します。

于 2012-12-13T06:07:54.407 に答える