How can i get the body data from Gmail

studio

#1

Hi.

I want to get the datas in highlighted in yellow from Gmail BODY and i want to create the Excel data table like this(image below)
Please let Me know how can i solve this problem…

46


#2

i want to create the excel table data like this


#3

Hi @muta
In UiPath you can use get text activity and store the value as string variable and use write range based on values you want to insert. Is there any please reply back

Thanks
AshwinS


#4

Hi @muta,

using Build Data Table create a table (From,Company,Telephone,MessageBody)

  • Use Get IMAP Mail Messages Activities, and get unread mails
  • Use For Each Activity and get Body data ->strMailContent
  • Use Matches activity to get the all the details

From Value:
Use Matches activity
Properties
Input : strMailContent
Pattern : ((?<=From:).*(?=Company:))
Result: iEnumResult ->IEnumberable<Match>
after that use assign activity to get the data
strFrom=iEnumResult (0).ToString()

Company Value:
Use Matches activity
Properties
Input : strMailContent
Pattern : ((?<=Company:).*(?=Telephone:))
Result: iEnumResult ->IEnumberable<Match>
after that use assign activity to get the data
strCompany=iEnumResult (0).ToString()

Telephone Value:
Use Matches activity
Properties
Input : strMailContent
Pattern : ((?<=Telephone:).*(?=Message Body:))
Result: iEnumResult ->IEnumberable<Match>
after that use assign activity to get the data
strTelephone=iEnumResult (0).ToString()

MailBody Value:
Use Matches activity
Properties
Input : strMailContent
Pattern : ((?<=Message Body:).*)
Result: iEnumResult ->IEnumberable<Match>
after that use assign activity to get the data
strMailBody=iEnumResult (0).ToString()

Now you got the four values into datarow.
using write range activity write the data in the excel file.

Regards,
Arivu :slight_smile:


Need to copy Name, Phone and Email
Extracting variables from .txt file
#5

Thank your for your reply! :blush:Actually I want to use get IMAP Mail Messages, and i cant understand how to get the specific data from email body text… But, I will try get text activity after this challenge!

Thanks!
Muta


#6

Thank your for your kindness.:relaxed: It was really helpful for me!!! But, I have a question. I cant use Matches Activity’s Pattern which you wrote down for me. Now, I use Matches Activity and Replace Activity but i really cannot understand how to set the Regex… Especially for

MailBody Value:
Use Matches activity
Properties
Input : strMailContent

Pattern : ((?<=Message Body:).*) ⇦⇦HERE!

I just want to get the data after (Message Body: )and i tried [.] or [.?] and so many things but it doesnt work… could you please give me some advise if you know some solution?:persevere::persevere::persevere:

Thanks,
Muta


#7

Hi @muta,

Try this pattern
((?=Message Body:).*)

Regards,
Arivu


#8

Hi @arivu96

Thank you for your reply again! :sob::sob::heavy_heart_exclamation:
but it didnt work for me…

Thanks


#9

Hi @muta,

Ya i got it what is the problem.

before processing Matches activity use assign activity to remove the new lines.
strMailContent=strMailContent.Replace(System.Environment.NewLine, "")+"#END"
i hope now you will get the answer.

((?<=Message Body:).*(?=\#END))

if you face any problem let you know.

Regards,
Arivu


#10

Hey, I tried this but when I am assigning strMailBody, I am getting an error that “object reference not set to an instance of an object” even after strMailBody is set as a string.


#11

Hi @kruttika_deshpande,

So the matching criteria is not available in the input string.

iEnumResult.Length>0
so before assign value check the value is not empty or null

Regards,
Arivu :slight_smile:


#12

Thank you so much


#13

Hey so where did you derive that pattern from?


#14

Hi @Max_Kirkman,

Use this below link to verify the pattern

Regards , Arivu :slight_smile:


#15

Thank you!


#16

Hi,

So disregarding the assign activity at the end. I think I’ve plugged in the correct stuff, yet pattern and result are still having compiler errors. I’ve substituted the respective column names in the pattern, yet problems have arisen. Can I please have some help.

Thank you in advance.


#17

Is the pattern and result still the same if my preceding selection was Outlook, as opposed to IMAP?


#18

Pattern: ((?<=Phone number :).*(?=Workplace name :))
Result: iEnumResult ->IEnumberable

Exactly as plugged in. Cheers, Max


#19

HI @Max_Kirkman,

can you send your input and expected output?

Regards,
Arivu :slight_smile:


#20

Sorry Idk what you mean by that?

The table consists of: “Name” , “Email”, “Phone number”, “Workplace name”, "Heard of us via"

The expected output focuses on: “Phone number”, “Workplace name” and “Heard of us via”.
Each are within the body of an email.

This was extracted from a ‘Build data table’ and this is going through a for each loop. Inside the for each loop is an if condition specified to finding the correct content in the body of an email.

Sorry for how abstract this is, I’m still unaware of how to upload stuff securely.

Cheers,
Max