私のアプリからメールを送信しようとするのが苦労しています。 は私が(http://icodeblog.com/2009/11/18/iphone-coding-tutorial-in-application-emailing/)MFMailComposeViewControllerのアプリからメールを送信する際の問題
-(void)sendEmail:(id)sender { MFMailComposeViewController *mail = [[MFMailComposeViewController alloc] init]; mail.mailComposeDelegate = self; if ([MFMailComposeViewController canSendMail]) { //Setting up the Subject, recipients, and message body. [mail setToRecipients:[NSArray arrayWithObjects:@"[email protected]",nil]]; [mail setSubject:@"Subject of Email"]; [mail setMessageBody:@"Message of email" isHTML:NO]; //Present the mail view controller [self presentModalViewController:mail animated:YES]; } //release the mail [mail release]; } //This is one of the delegate methods that handles success or failure //and dismisses the mail - (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error { [self dismissModalViewControllerAnimated:YES]; if (result == MFMailComposeResultFailed) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Message Failed!" message:@"Your email has failed to send" delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil]; [alert show]; [alert release]; } }
をiCodeBlogから、このコードを試してみましたそれは、電子メールを送信していないと言いますエラーが発生しますが、受信トレイにはメールが届きません。 別のメールアカウントに送信しようとしましたが、別のアカウントからも送信しようとしましたが、エラーは発生しませんでしたが、メールを受け取ることはありません。 アイデア
それが重要な場合、私はへの入力を開始するとき、私はデバッガコンソールにこのメッセージが表示されます:メール
DAを| /tmp/DAAccountsLoading.lockでロックファイルを開けませんでした。 ===============================私たちは、とにかくアカウントをロードしますが、悪いことは
が起こることがあり====== EDIT ===================== 私はそれを実現しましたこれらのメールはすべてMail.appの送信トレイに送られました。送信をクリックすると自動的に送信されませんか?そうでない場合、ユーザーがMFMailComposeViewの[送信]ボタンを押したときに、それらを送信させるにはどうすればよいですか?あるいは、Mail.appを呼び出してそれらの電子メールを送信することもできます。
コードが混乱しているように見えますが、私は多くのアプリケーションでメールコンポーザーを実装していますが、これは絶対にうまく動作します – Aditya
あなたのコードはいくつか役立ちました。ありがとう! –
コードが見当たらずに見える場合、コードとして表示されていない行の前に必要なスペースが4つありません。 –