Get ID and references from a Gmail e-mail

Hello everyone,

I want to extract data from mails from GMail, no issue around the fact to extract body subject etc …
But I want to put the reply of an exchange of e-mail in the same line of an excel. In order to do that I have to identify that my mail is a reply to one of the e-mail that I have already report in my excel.
I consider that the subject of the e-mail is not a solid argument and I want to base my identification via the ID of each mail.

For example here :

I have the ID of my e-mail and in References, all the ID from the previous exchange of e-mails.

But impossible to extract those datas with UI Path, do you have any idea / tips ?

I hope that it’s clear



Hi @Adrien_Poude,

Could you please let me know what activity do you use to get Gmail emails?

I have few solutions to check for you:

    • The value for Email ID can can be retrieved from the MailMessage.Headers("Uid") object or from the UiPathEventObjectId project argument if an Integration Service trigger is used.
  1. Check this tutorial, it should answer your question as well:
    UiPath Tutorial 09 - Read Email in UiPath | Filter Email in UiPath | Get IMAP Mail Messages Activity - YouTube

  2. API:
    You need to do a list as described here first (it has search semantics in the q parameter if you are not interested in all messages):

This returns a list of messages which look like this:

The message id is the id field (“id”: string)

Let me know if that works :wink: If so, please mark as the solution :slight_smile:


1 Like

Hi @kmisko11,

Thanks a lot for your reply.

I use “Use Gmail” activity and after i use a for each and after I extract my data with CurrentMail…

Indeed I can find an ID thanks to your first point but I cannot find the references that I need for my use case.

I think that I can solve my issue thanks to your third point with :

But how can I get those datas in UI Path in my for each loop ?

Thanks again,



The third option requires to use API for all the sequence for gmail emails gathering.
You would need to send API request to get the emails and then loop through the JSON to get the correct data. Unfortunately, it will require some more effort to authenticate with google account and find the correct parameters. I have not used it much but if there will no other option, I will try to assist you :wink:


Do you think that it’s possible to get id from previous mail thanks to this kind of expression ?

Hmm, what exactly means “previous mail” here?
Is it the previous mail while looping through gmail emails or the mail from outlook?

I mean that I need to get the ID of the email but I need too to get the id of the previous mail in a same exchange of email.
If I receive a mail, that I answer and that i receive one more mail in this exchange.When I will receive the last mail, I need to get the ID of last mail but the ID of the first mail too.
The references in my screenshot.


@kmisko11 Let me know if you have any tips for this point and in any case thank you for your help !


I am not sure if I understood correctly the case. Is it possible to send the components or kind of logic map? Otherwise we can think about short call to understand the issue :wink:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.