Gmail Auto-Reminder Script Issue

I’m having trouble with a Gmail script for sending reminder emails. Here’s what I want it to do:

  1. Send a “Kind Reminder” to someone who hasn’t responded to my original email
  2. Keep the reminder in the same thread as the original message

My current script isn’t working right. It’s sending the email to me instead of the recipient. Also, it’s not using my name in the “From” field, and the message body shows [object Object] instead of my reminder text.

Here’s a simplified version of what I’m trying to do:

function sendReminder() {
  var recipientEmail = '[email protected]';
  var reminderText = 'Just checking in on our previous conversation.';

  GmailApp.sendEmail(recipientEmail, 'Friendly Reminder', reminderText, {
    name: 'Your Name',
    threadId: originalThreadId
  });
}

Can anyone help me fix these issues? I’m new to Gmail scripting and could use some guidance. Thanks!

hey there CharlieLion22, i had similar issues when i started with gmail scripts. for the recipient problem, double-check ur recipientEmail variable. the [object Object] thing usually means ur trying to use an object as a string. make sure reminderText is actually a string. for the name, try using ‘from’ instead of ‘name’ in the options. hope this helps!

I’ve encountered similar challenges with Gmail scripts. A few suggestions:

Check if you’re using the correct Gmail API scope. You might need to add ‘https://www.googleapis.com/auth/gmail.send’ to your project’s OAuth scopes.

For the ‘From’ field issue, try using the ‘from’ parameter instead of ‘name’ in the options object. For example:

GmailApp.sendEmail(recipientEmail, 'Friendly Reminder', reminderText, {
  from: 'Your Name <[email protected]>',
  threadId: originalThreadId
});

The [object Object] error typically occurs when an object is passed as a string, so ensure reminderText is indeed a string rather than an object.

Lastly, verify that originalThreadId is correctly set to the thread’s ID. You can retrieve it using GmailApp.getThreadById().

I’ve been working with Gmail scripts for a while now, and I think I can help you out. The issue with sending emails to yourself instead of the recipient is likely due to how you’re setting up the sendEmail function. Make sure you’re passing the recipient’s email as the first parameter.

For the name problem, try using the ‘from’ parameter in your options object like this:

GmailApp.sendEmail(recipientEmail, ‘Friendly Reminder’, reminderText, {
from: ‘Your Name [email protected]’,
threadId: originalThreadId
});

As for the [object Object] issue, it sounds like your reminderText variable might be an object instead of a string. Double-check how you’re defining it.

One last tip: to keep the reminder in the same thread, make sure you’re correctly setting the originalThreadId. You can get this from the original email using something like GmailApp.search(‘subject:Your Original Subject’)[0].getId().

Hope this helps you get your script working!