私は電子メールで単一の電子メールアドレスに送信したいテキストフィールド(5フィールド)からなる連絡フォームを持っています。 xCodeでこれをどうやって行うのですか?お問い合わせフォームを電子メールで送信
0
A
答えて
0
リンクされた投稿にも同様の回答がありますが、canSendMailが既にチェックされているので、私のコードを追加しています。私はまた、電子メールに他のものを追加するのを容易にするコメント付きコードを残しました。あなたが唯一の私は、このコードを使用する無料アプリ、QCountを、持っている
のiOS 5をターゲットにしている場合、これは、実質的に容易であること
注意。確かに、私はあなたの.hで、私はhttp://itunes.apple.com/ng/app/qcount/id480084223?mt=8
お楽しみください:-)私のコピー&ペーストからカスタムのすべてを剥奪
ダミアン
を願っています:あなたの中
#import <MessageUI/MessageUI.h>
メソッド。 m:
- (void)emailLabelPressed { // or whatever invokes your email
// Create a mail message in the user's preferred mail client
// by opening a mailto URL. The extended mailto URL format
// is documented by RFC 2368 and is supported by Mail.app
// and other modern mail clients.
//
// This routine's prototype makes it easy to connect it as
// the action of a user interface object in Interface Builder.
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];
}
}
-(void)displayComposerSheet {
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[picker setSubject:@"Your Form Subject"];
// Take screenshot and attach (optional, obv.)
UIImage *aScreenshot = [self screenshot];
NSData *imageData = [NSData dataWithData:UIImagePNGRepresentation(aScreenshot)];
[picker addAttachmentData:imageData mimeType:@"image/png" fileName:@"screenshot"];
// Set up the recipients.
NSArray *toRecipients = [NSArray arrayWithObjects:@"[email protected]", nil];
// NSArray *ccRecipients = [[NSArray alloc] init];
// NSArray *bccRecipients = [[NSArray alloc] init];
// NSArray *ccRecipients = [NSArray arrayWithObjects:@"[email protected]", @"[email protected]", nil];
// NSArray *bccRecipients = [NSArray arrayWithObjects:@"[email protected]", nil];
[picker setToRecipients:toRecipients];
// [picker setCcRecipients:ccRecipients];
// [picker setBccRecipients:bccRecipients];
// Attach an image to the email.
/* NSString *path = [[NSBundle mainBundle] pathForResource:@"ipodnano"
ofType:@"png"];
NSData *myData = [NSData dataWithContentsOfFile:path];
[picker addAttachmentData:myData mimeType:@"image/png"
fileName:@"ipodnano"];
*/
// Fill out the email body text.
// NSString *emailBody = @"Use this for fixed content.";
NSMutableString *emailBody = [[NSMutableString alloc] init];
[emailBody setString: @"Feedback"];
// programmatically add your 5 fields of content here.
[picker setMessageBody:emailBody isHTML:NO];
// Present the mail composition interface.
if ([self respondsToSelector:@selector(presentViewController:animated:completion:)]) {
[self presentViewController:picker animated:YES completion:nil];
} else {
[self presentModalViewController:picker animated:YES];
}
}
- (void)mailComposeController:(MFMailComposeViewController *)controller
didFinishWithResult:(MFMailComposeResult)result
error:(NSError *)error {
if ([self respondsToSelector:@selector(dismissViewControllerAnimated:completion:)]) {
[self dismissViewControllerAnimated:YES completion:nil];
} else {
[self dismissModalViewControllerAnimated:YES];
}
}
-(void)launchMailAppOnDevice {
NSString *recipients = @"mailto:[email protected][email protected],[email protected]&subject=Hello from California!";
NSString *body = @"&body=Feedback";
NSString *email = [NSString stringWithFormat:@"%@%@", recipients, body];
email = [email stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:email]];
}
1
この問題を抱えている人は、 iOSのコンタクトフォームにドロップインします。
これは私のニーズによく合っており、PHPコンポーネントを使用して実際に電子メールを送信します。 。(例えば、スクリプトはサンプルプロジェクトに含まれている
私はここのGithubにそれを投稿:
+0
これを共有してくれてありがとう、それは素晴らしいです!:-) – kernix
関連する問題
- 1. お問い合わせフォーム(specificeのslection)と電子メール
- 2. お問い合わせフォーム - 送信者にメールを送信しますか?
- 3. メールお問い合わせフォーム
- 4. Drupalのお問い合わせフォーム私に重複したメールを送信
- 5. PHPお問い合わせフォーム - 電子メールアドレス/ホストパートへの投稿?
- 6. WordPressデータベースにお問い合わせフォームを送信
- 7. 電子メールとGoogleドキュメント(フォーム)に送信
- 8. お問い合わせフォーム
- 9. Liferay Webフォームから電子メールを送信できません
- 10. iOSで電子メールを問い合わせる方法
- 11. 送信する/電子メールを送信するフォームを取得
- 12. ページ電子メールで送信
- 13. UIImage電子メールで送信
- 14. PHPを使用せずにお問い合わせフォームを送信
- 15. rails 3電子メール送信の問題
- 16. Codeigniter - 電子メールを送信
- 17. ASP.NET-電子メールを送信
- 18. vb.net電子メールを送信
- 19. wordpress登録フォームが電子メールを送信できない
- 20. PHPお問い合わせフォームは送信されませんか?
- 21. PHPお問い合わせフォーム空白のメール
- 22. お問い合わせフォーム7のポートフォリオ品目の名前を送信する
- 23. CDO - 電子メールを送信しても電子メールを送信すると
- 24. Asp.net電子メール送信プロセス
- 25. ASP電子メール送信エラー
- 26. お問い合わせフォームメールを送信しない
- 27. フォーム送信後にPHPスクリプトが電子メールを送信しない
- 28. PHPなしでhtmlフォームから電子メールを送信
- 29. 電子メールでWebフォームを送信する方法
- 30. htmlフォームを電子メールでpdfとして送信
はすでに[SO](http://stackoverflow.com/questions/7087199/xcode前の答え-4-ios-send-an-email-using-my-app-inside-my-app) –