Not able to read gmail subject

I have used Get IMAP mail messages to retrieve email from gmail account.Tried with various functions mail messages, get text by supplying exact text /subject line but it is failing to read the message even if it is existing there.
Any help on how to read subject / email in “For each” loop would be hlepful

Thanks
Vaibhav

@vaibhavp2 take for each loop configure argument type to mail message…then take assign activity give mail.subject

once you read emails output will be list of mail messages,
hence you have to loop through each mail one by one, Use for each activity:
change argument type to type of the output of readMailMessages activity.
inside for each you can use item.subject / item.Message

Hey Vaibhav,

as @Divyashreem suggested, you need to set for each variable type to System.Net.MailMessage

as shown below
image

after that you should acess mail Subject is as below
item.Subject
item.Body for bodyetc

Regards
Aditya

Thank you for your prompt response aman_sheik , @Divyashreem and @aditya.prakash.

I was fairly able to understand your submission but please bear with me as I am not from core development background. Let me try to explain the the use case I am trying to achieve:
To start with, I have used Try - catch and inside Try , I have used a sequence in which first I am using “Get IMAP mail messages” and after this I am using For-Each ( as shown below).

So I want to read mail subject in such a way that once execution is triggered, it should search for the text that I am supplying and if it finds the same text/match in mail subject, it should enter into ‘Then’ and execute say data scrap sequence, else display a message that says for example : “Mail is not yet received.”

I know something is getting wrong though studio doesn’t show any error in my current setup here but I am just trying to think logically and may not be with programming perspective.

In case if it is getting difficult to explain over conversations, would you mind sharing any sample project file so that I can practically see how it works.

Thanks a lot !
Vaibhav

Hey Vaibhav,

have this sample

imapMailSolution.xaml (7.3 KB)

regards
Aditya

Thank You @aditya.prakash for sharing sample.

I believe it is working to some extent. ( I have attached my sample .XAML, you can add your email credentials as it may give error on IMAP activity otherwise).
What I am experiencing with this solution is that it is not stopping after getting the required subject line of email. It shows me up with both the activities that I have in my “if-then” condition ( in my case it is 5 times because I have restricted to read ‘Top’ 5 mails).

I don’t know if it is getting wrong after “Assign”. Because as you know, use case is to trigger some browser operations like login , data scrap, Datadump only if we find the mail with that subject line or else it should simply say email not yet received and stop whole flow.

Sample_VersionDump.xaml (13.8 KB)

Thank you,
Vaibhav

Hey Vaibhav,

I has created one sample for you which you wanted!!
please find the sample with Assign,

Note: you can access this Assign variable under for Each> if block only, so you need to invoke browser operations in if block only! Another way is that you can change the scope of the variable and store the variable in list and then you can access that inside for each loop where ever you wanted!

Hope it will Help you

Sample_VersionDump1.xaml (17.2 KB)

1 Like

Hello Thanks for Answer. I wanted Answer to this question,
When you use IMAP activity, the mail you receive in which format? And how you can convert into string?. Please reply.

Regards
Rohit Lanjewar