question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

send email on same thread.

See original GitHub issue

I have received a successful response of a email using gmail.users.messages.send() which is like
{ "id": "1231212312", "labelIds": ["UNREAD", "SENT", "INBOX"], "threadId": "23123123" }

I need to send an email again to the same email address but on the same thread not as a new email i.e using thread id to send email.

Need Help!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:16 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
JustinBeckwithcommented, Jun 20, 2019

Greetings! For support with the API, please go here: https://developers.google.com/gmail/api/support

1reaction
zorioncommented, Oct 30, 2020

Hi sudb97! I’m glad you have something working!

I am not sure we are doing the same so in case my needs can fit yours I add a metadata sample. It works for us with the following metadata (with some part redacted just in case).

In-Reply-To: < 20200226123023.10596.23989@gceworker1.c.redacted.internal*> References: < 20200226123023.10596.23989@gceworker1.c.redacted.internal*> Date: Wed, 26 Feb 2020 04:30:24 -0800 Message-ID: CAAe2CVM***redacted*****ny+=Q@mail.gmail.com

When I send the e-mail I do include “In-Reply-To” and “References”. This is the fake ID, and my first e-mail already “replies” to the fake id e-mail. The field Message-Id I don’t send, it is generated way after I send the “send e-mail” request. I assume the send request is not directly a send, so the e-mail doesn’t have a message-id until it is indeed sent in the server’s background (this is an assumption on why the send request doesn’t return the message-id).

This meta data above I got from the e-mail I sent in my GMAIL web ui message -> 3 vertical dots -> show-original

So the process was:

  1. I generated a fake message-id from the server and I got 20200226123023.10596.23989@gceworker1.c.redacted.internal*
  2. I made the e-mail with the in-reply-to and references including the fake id generated
  3. I requested gmail api to send the first e-mail with those fields sets
  4. I requested gmail api to send the other e-mail with those fields set same way (same in-reply-to and references)
  5. I can see all of them in the same thread and I can now get the message-id if I wanted to.

On the other hand, technically I assume that it works like this: I tell gmail that I have a (fake) local e-mail I am replying to with the fake id that may be currently deleted. I tell gmail that all e-mails I am sending are direct replies to that same fake local e-mail. GMail groups all these e-mails because they are related, they are a conversation to the fake e-mail, but they don’t have dependencies to each other except for the timestamps so Gmail groups them and sorts them by timestamp. I am not sure this is the case but it works for us like a charm!

If you send the first e-mail and want to use its message id you are doing it properly, but you will need to wait until the message-id is indeed generated which may not be immediate.

Of course you may dismiss this e-mail since it’s a workaround and you have your own workaround. Having the message-id in the send-email-request is what both of us would miss.

Best regards, Zorion

On Wed, Oct 28, 2020 at 7:44 AM sudb97 notifications@github.com wrote:

Hi Zorion,

Yes i tried using fake-ids, it wasn’t working.

But i used https://developers.google.com/gmail/api/reference/rest/v1/users.messages/get?authuser=1 https://developers.google.com/gmail/api/reference/rest/v1/users.messages/get?authuser=1 gmail API to get my message-id. It worked fine.

Gmail automatically assigns a Message-id to the mail you are sending via its api.

I was just not able to get the correct api request.

Now i am able to thread all the replies.

Just working on how to retrieve the message-ids for email sent via my python code. Then will be able to send replies that will be chained.

Thanks for your code though 😃

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/googleapis/google-api-nodejs-client/issues/710#issuecomment-717734859, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQ63B2XCGD2WITTUABNVVDSM64T3ANCNFSM4DAURQ2A .

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to send follow up emails in the same thread as previous ...
When you're creating a new email campaign, you see an option named "Send followup in the same thread". If this option is enabled, ......
Read more >
How to send a second email to the same recipient when you ...
If you've sent an email to someone and then want to send another as part of the same conversation or "trail" (e.g. if...
Read more >
Email threading and how to change your threading mode
Messages with the same subject line will be threaded together, only if the email recipients are the same. Messages will only thread by...
Read more >
Is there any way to send an email in the same thread?
First thing, you need to set a Message-ID header in the MimeMessage object, in the exact format Gmail is expecting ("<anyidyouwant@domain.com>", ...
Read more >
Email Thread - Meaning, How To Forward It, Best Practices
An email thread is a record that groups together all email replies for an email instead of showing all the emails individually and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found