Multiple conditions to be met in UiPath Studio

Hi everyone,

I’m trying to create a condition by using the IF activity and get an error of:
Object reference not set to an instance of an object

the condition should be

mail.Subject.ToString.Contains(“SOA Request 1st Attempt”) and mail.body.ToString.Contains(“Delivery has failed to these recipients,Your message couldn’t be delivered to multiple recipients.”) AndAlso mail.From.ToString.Contains(“Microsoft Outlook,PostMaster,postmaster@xmalimited.onmicrosoft.com”)

Thanks in advance!

@Lainyvi_Santoc,

Your conditions looks fine.

The error message “Object reference not set to an instance of an object” in UiPath typically occurs when your workflow is trying to access or use an object that has not been initialized.

Check if your mail variable is not nothing before using it.

Thanks,
Ashok :slight_smile:

1 Like

thanks for this Ashok!

still not getting the reason why. I had already check all the variables but doesn’t work

this is the workflow

can anyone help me with the error still getting the same. thanks!

Debugging, debugging, debugging! You have all the tools in your studio to find which object has not been initialized.

Cheers

@Lainyvi_Santoc Can you send whole condition which you are putting in If activity?

@Lainyvi_Santoc,

I’m able to reproduce the scenario you are facing.

Root cause:
It’s due to Undeliverable email. These emails don’t hold any Sender or From data so it’s null. See this:

image

Solution:

This if condition will give you only undeliverable emails.
item.Subject.StartsWith("Delivery has failed") AND item.From is Nothing and item.From is Nothing

Test Code:
MailCompare.xaml (14.1 KB)

Output:
image

You can thank me by marking this as Solution if it works :stuck_out_tongue:

Thanks,
Ashok :slight_smile: