Say my address is myself@gmail.com , and I have this thread in gmail:
Thread1 ======= Email1 From: customer@example.com To: myself@gmail.com Content: Hello, I have a question about your product. Email2 From: myself@gmail.com To: customer@example.com Content: We have received your email, we will answer soon.
When using this Javascript code in Google Apps Script using the reply GmailThread method:
var threads = GmailApp.search(...); var thread = threads[0]; // this is our Thread1 thread.reply(body, {htmlBody: htmlbody, from: " myself@gmail.com "});
it will actually answer me! (ie email from yourself to the email address from the email itself @@@ mail.google@gmail.com )
In fact, the dock says:
answer (body)
Reply to the sender of the last message in this thread
How to avoid this when using GmailThread and have a reply reply to the original author?
Note. This can be tricky, because sometimes Gmail “groups” in the same thread chains that are not between the same two people. So, for example, if there was mail a month before, with the same question:
Email0 From: anothercustomer@example.com To: myself@gmail.com Content: Hello you.
then it will be grouped in the same gmail stream ! This means that we cannot use this simple solution: "let's use From first message in the stream."
source share