1

ヘルプを探しています。iPhone プログラミングは初めてです。

Pagesheet を使用せずに、作成 UI を開かずに、デバイスで構成された標準アカウントを使用してメールを送信する方法はありますか?

電子メールのリマインダーを送信するアプリを作成したいと考えています。

あなたからのリプレイを聞くのを楽しみにしています

ありがとう...

4

3 に答える 3

1

任意のコンポーザー ウィンドウを使用してバックグラウンドでメールを送信できます

このSMTPSenderの例を参照してください

例:

- (BOOL)send
{
    NSAssert(sendState == kSKPSMTPIdle, @"Message has already been sent!");

    if (requiresAuth)
    {
        NSAssert(login, @"auth requires login");
        NSAssert(pass, @"auth requires pass");
    }

    NSAssert(relayHost, @"send requires relayHost");
    NSAssert(subject, @"send requires subject");
    NSAssert(fromEmail, @"send requires fromEmail");
    NSAssert(toEmail, @"send requires toEmail");
    NSAssert(parts, @"send requires parts");

    if (![relayPorts count])
    {
        [delegate messageFailed:self
                          error:[NSError errorWithDomain:@"SKPSMTPMessageError"
                                                    code:kSKPSMTPErrorConnectionFailed
                                                userInfo:[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Unable to connect to the server.", @"server connection fail error description"),NSLocalizedDescriptionKey,
                                                          NSLocalizedString(@"Try sending your message again later.", @"server generic error recovery"),NSLocalizedRecoverySuggestionErrorKey,nil]]];

        return NO;
    }

    // Grab the next relay port
    short relayPort = [[relayPorts objectAtIndex:0] shortValue];

    // Pop this off the head of the queue.
    self.relayPorts = ([relayPorts count] > 1) ? [relayPorts subarrayWithRange:NSMakeRange(1, [relayPorts count] - 1)] : [NSArray array];

    NSLog(@"C: Attempting to connect to server at: %@:%d", relayHost, relayPort);

    self.connectTimer = [NSTimer scheduledTimerWithTimeInterval:connectTimeout
                                                         target:self
                                                       selector:@selector(connectionConnectedCheck:)
                                                       userInfo:nil
                                                        repeats:NO];

    [NSStream getStreamsToHostNamed:relayHost port:relayPort inputStream:&inputStream outputStream:&outputStream];
    if ((inputStream != nil) && (outputStream != nil))
    {
        sendState = kSKPSMTPConnecting;
        isSecure = NO;

        [inputStream retain];
        [outputStream retain];

        [inputStream setDelegate:self];
        [outputStream setDelegate:self];

        [inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop]
                               forMode:NSRunLoopCommonModes];
        [outputStream scheduleInRunLoop:[NSRunLoop currentRunLoop]
                                forMode:NSRunLoopCommonModes];
        [inputStream open];
        [outputStream open];

        self.inputString = [NSMutableString string];



        return YES;
    }
    else
    {
        [self.connectTimer invalidate];
        self.connectTimer = nil;

        [delegate messageFailed:self
                          error:[NSError errorWithDomain:@"SKPSMTPMessageError"
                                                    code:kSKPSMTPErrorConnectionFailed
                                                userInfo:[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Unable to connect to the server.", @"server connection fail error description"),NSLocalizedDescriptionKey,
                                                          NSLocalizedString(@"Try sending your message again later.", @"server generic error recovery"),NSLocalizedRecoverySuggestionErrorKey,nil]]];

        return NO;
    }
}
于 2012-11-07T06:05:48.303 に答える
1

管理するサーバーに情報を送信する必要があり、smtp タイプの方法でメールを送信するだけです。

于 2012-11-07T05:57:59.547 に答える
0

1)作成 UI を開かずに、デバイスで構成された標準アカウントを使用してメールを送信する方法はありますか

いいえ、あなたがすることはできません。

別の方法:

特定のアドレスに電子メールを送信する Web サービスを作成できます。

于 2012-11-07T06:02:21.897 に答える