iPhone アプリ内から HTML 形式のメールを送信しています。アプリケーション パッケージ内に格納されている HTML ファイルを読み込んでいます。
ここで、HTML ファイル内の特定のテキストを変更したいと考えています。つまり、アプリでのユーザーの特定の選択に応じて変更される名前、電子メール、電話があります。
これらのさまざまなパラメーターを HTML ファイルのコンテンツに追加するにはどうすればよいですか?
助けてください。
ありがとう
iPhone アプリ内から HTML 形式のメールを送信しています。アプリケーション パッケージ内に格納されている HTML ファイルを読み込んでいます。
ここで、HTML ファイル内の特定のテキストを変更したいと考えています。つまり、アプリでのユーザーの特定の選択に応じて変更される名前、電子メール、電話があります。
これらのさまざまなパラメーターを HTML ファイルのコンテンツに追加するにはどうすればよいですか?
助けてください。
ありがとう
このようなものがあなたのために働くかもしれません:
NSString *htmlPath = [[NSBundle mainBundle] pathForResource:@"yourHtml" ofType:@"html"];
NSError *error = nil;
NSString *inputHtml = [[NSString alloc] initWithContentsOfFile:htmlPath encoding:NSUTF8StringEncoding error:&error];
NSString *nameParsedHtml = [inputHtml stringByReplacingOccurrencesOfString:@"Name:" withString:[NSString stringWithFormat:@"Name: %@", self.nameField.text]];
NSString *emailParsedHtml = [nameParsedHtml stringByReplacingOccurrencesOfString:@"Email:" withString:[NSString stringWithFormat:@"Email: %@", self.emailField.text]];
NSString *outputHtml = [emailParsedHtml stringByReplacingOccurrencesOfString:@"Phone:" withString:[NSString stringWithFormat:@"Phone: %@", self.phoneField.text]];
NSLog(@"Output html string is: %@", outputHtml);