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.