I am working on a Google Apps Script project where I need to send a reply to a specific message within a Gmail thread using the GmailApp service. However, I have encountered a couple of challenges that I'm seeking assistance with.
Firstly, I want to send the reply to the recipient of the first message in the thread, which was originally sent by me. I have tried using the GmailApp service, but it only sends the reply to the sender (me) by default. I am wondering if there is a way to write a snippet code to send the reply to the recipient instead, allowing me to send a follow-up reminder. I have the thread ID and will recall the reply email body from another sheet cell in Google Sheets. Secondly, I need to preserve the formatting of the reply email body, which is stored in a cell of another sheet. The body contains multiple paragraphs, and I want to avoid merging the lines of the email body and preserve the font size. I am unsure of the best approach to achieve this using GmailApp. Should I consider using HTML body or explore alternative methods?
Furthermore, I would like to quote the original message within the reply email, similar to how Gmail UI quotes the original message in a reply. Specifically, I want to include the original message below the email body of the reply, showing the sender, date, and the original message content. For example, something like:
"On Fri, Jun 23, 2023 at 4:32 PM Hamed [email protected] wrote:
Dear--------,
I hope this email finds you well."
I would appreciate any guidance to address these challenges and achieve the desired functionality within my Google Apps Script project.
Thank you in advance for your assistance!
Suggestion:
The script below works as follows
GmailAppservicesample sheetI made with asample paragraphusingSpreadSheetAppServiceScript:
Sample Thread:
Reply Email using the script:
References:
Class GmailApp
GetTo method
CreateDraft method
reply method