Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9782

Is it possible to change the message type in apps Script and google-sheets [closed]

$
0
0

I use a script bound to a Google spreadsheet to send a “I forgot my password” message by email.

I want to vary the message based on the following conditions:

  1. The email address is empty
  2. The email address doesn't match any registered

If the email is registered, a message appears: The password has been sent to the emailThe script used in script.google

for (var i = 0; i < values.length; i++) {  if (values[i][0] == email) {    var name = values[i][1];    var password = values[1][2];    var message = 'Hello '+ name +' .\n\nYour password is: '+ password;    var subject ='Forgot your password';    var recipient = email;    MailApp.sendEmail(recipient, subject, message);    var found_record = '';    break  }}if (found) {  return 'Welcome, '+name+'\nPassword sent to email.';} else {  return 'Email address not found, Try Again.';}<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script><div class="wrapper"><h2>Contact us</h2><div id="error_message"></div><form  onsubmit="event.preventDefault(); submitForm(this);"><div class="input_field"><input type="text" placeholder="Email" id="email" name="email"></div><div class="input_field"><textarea placeholder="Message" id="result" name="message">TryAgain</textarea><!-- <textarea  id="result" >TryAgain</textarea>--></div><div class="btn"><!--  <input type="submit" value="Submit"id="submit">--><input id="submit" type="submit" value="Forgot Password" onclick="alertWithMessage()"/></div></form><script>let timeout;function alertWithMessage() {  timeout = setTimeout(alertFunc, 3000);}function alertFunc() {   var message = document.getElementById('result').value;  Swal.fire (message );}</script><script>function submitForm(form) {google.script.run.withSuccessHandler(function(result) {document.getElementById('result').textContent = result;form.reset();}).processForm(form);}</script>

Viewing all articles
Browse latest Browse all 9782

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>