Unable to store all gmail emails into List<MailMessages> variable

Hello Everyone, I’m a beginner in UI Path and I have been trying my hands on Email Automation. I want to store all Gmail emails in into a List (Variable Type). But I am getting Compiler error. Please find the attached screenshot.

I am trying to create a workflow which should get triggered when a mail with a specific subject line is received in Inbox.

@Bhaskar_Mukka Out property(MailMessages) of Get IMAP mail messages stores all your mails in list format(In Your case AllEmails variable contains mails is list format[Type will be System.Net.Mail.Message) only no need assign again to new list variable), After that you can use for each activity to get individual mail. Anyway why your using assign statement? any specific reason.

1 Like

Hi,
AS @Manjuts90 said you have to use For Each activity. since the output mails are stored in a list you cannot directly assign those to a variable. If you want to get the subject of each mail,

1.Use For Each activity of Type argument System.Net.Mail.MailMessage and iterate the list.
2. Inside for each you can directly get the subject by item.Subject.

Thanks.

1 Like

Thanks @Manjuts90 & @Uthraa,

But I am trying to Create a Bot which should get triggered when a mail with a specific subject line is received in Inbox. I have gone through the link Option Strict On disallows late binding
from Mr.RishiVC1 he was doing the same using Outlook.

Please find my workflow screenshot below.

@Bhaskar_Mukka what error u getting?

One or more children have validation errors or warnings.

@Bhaskar_Mukka can u share ur workflow?

I have already shared all the screen. please look into my previous message.

Hi @Manjuts90,

I removed my user name (gmail account) and password. Please add your email and password to check the process.

image

@Bhaskar_Mukka where u will find submission received string in subject or body.

In mail Subject

@Bhaskar_Mukka instead of giving decision box give for each loop, inside loop with if condition check whether each mail subject contains ur required string, and if required string is present do ur activities, after for each activity give flow back to get mail messages activity. remove flow decision from ur current workflow.

Ok @Manjuts90 Thanks for support :slight_smile:

1 Like

@Bhaskar_Mukka is it working for you?

@Manjuts90 Yes it is working. but, if my condition satisfies how should I break the process.

image

@Bhaskar_Mukka Assign true value to boolean variable inside then part part if statement. Again looping back to Get imap mail messages activity check the condition of boolean variable if it is false go back to get imap mail messages activity, if it is false give give appropriate action u want to take.

Hi @Manjuts90,

How can I assign true value to boolean variable inside then part part if statement. Is it in properties panel or in variables panel?

mail.Subject.Contains(“Submission Received”) = true

is the above statement correct?

@Bhaskar_Mukka Check below workflow for ur reference.

expNew.xaml (13.3 KB)

Thank you @Manjuts90 its working :slight_smile:

1 Like

@Bhaskar_Mukka Your welcome If you got solution close thread marking as solution.