Object reference not sent to an instance of an Object

I am trying to read body of the emails from outlook which has following details and get The value of website URL, Name, Phone, Email etc… using regex match and testing it a write line activity.

Website URL: http://www.somthing.com
Name: Something
Email: Something@Something.com
Phone: 12345
Referal URL: https://www.Something.com/search?q=Something&src=IE-TopResult
Referal Landing URL: Something.com/
IP address: 255.255.255.205
Affiliate Id: 1234

In few email body some of these details are missing. e.g, Referal URL will not be present. In such cases I get ‘Object reference not sent to an instance of an Object Write line error’. Saw in some forum they asked me to try str_output = IF(String.IsNullOrEmpty(str_input.ToString)," ",str_Input.ToString).ToString. But I get the same error for Assign activity. Please help with a solution. How to assign the value of those missing strings as ‘N/A’?

Hy @Arjun_Prasad,

I believe you are using the ‘Matches’ activity to get data from the email, is that right?
This activity retrieves an collection of objects, before populating the variable check if item was found with an ‘if’ activity, like this : Matches.Count > 0 then Fill the variable.

Any questions please let me know!

Regards

Yes. I am using matches activity to get data from email.

I am sorry I am new to UIpath. Can you provide me with a tutorial or a screenshot of how to use the IF with the condition and then how to populate the variable?

@Arjun_Prasad

Use IsNothing(YourString) in IF condition

Hope this helps

Thanks

Hy @Arjun_Prasad, try this:

image

if there are items found in the Regex, assign the first item found to your variable, is that clear?

Regards

That worked!
Thank you so William!

Hy @Arjun_Prasad, glad I could help you!!

Could you please mark my answer as the final solution?

Thank you!

Happy automation

Done!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.