Assign: Object reference not set to an instance of an object. Error happens when looping specific mail list

This error happens during looping mail list, while retrieving specific mail in the list. count of the list is 40 and the error pop up when count reach 23. I tried to retrieve its body or address, it shows null. How does that happen and why? and is there any way to know if the next mail is null or not before executing any operations on it? anyway I appreciate your reply.

Hi @esraa_elzoghby ,

Try the expression string.IsNullorEmpty(mail.Sender.Address) in the if activity. If it is null then it will skip it and if not then use assign activity.

And if these works mark it as the solution.

Happy Learning,
Achal Sharma

Hi @esraa_elzoghby

You can try something like below!

Use the expression in if condition in for each mail


Refer to the screen shot.


Don’t work.

can you show me the value at which it is throwing an error?

I tried but It doesn’t work.
if error

Hi @esraa_elzoghby

Alternate way is we can try with this expression!

item.Sender.Address.ToString isnot Nothing


try mail.sender.address.tostring instead of mail.sender.address.tolower

I tried also tried mail.From.Address.tostring, error still occurs

don’t work

Hi @esraa_elzoghby

Give a try on below condition

mail.sender.address.tostring.length =0 or
mail.sender.address.tostring.Count =0

Then part leave blank

else part assign the email


Not working too, I think the problem is the calling of this specific mail sender address, when calling subject is working but display null also this email body is null.

I printed all mails subjects one of them which causes the error displayed as null, I think there is no address to call so that the error still occur.
null mail