NullReferenceException - Outlook mail messages

Main has thrown an exception

Source: If

Message: Object reference not set to an instance of an object. This error usually occurs when using a variable with no set value (not initialized).

Exception Type: NullReferenceException

System.NullReferenceException: Object reference not set to an instance of an object.


Main.xaml (6.7 KB)

I guess Get outlook mail messages activity is not getting any mails from the inbox.
so the mails list might be empty. That could be the reason for NullReferenceException

To debug, try displaying mails.count before the For each activity.

if i dont use “if” condition its working fine
when using “if” condition i am getting that error

you mean to say, if you don’t use if, you are able to print item.subject?

yes @kaderms

Can you try item.From.Address = "marketing@linuxacademy.com" in your if condition?

still same error

Hello Tanuja,
The xaml which you have attached is working fine.
Try this:
-In properties of Outlook mail activity, specify account name. First try to get first 5 or 6 mail.
If above not works:
-Try same by disabling your antivirus (But i don’t think antivirus block get outlook mail activity).
-Which version of Studio are you using?

Update the outcome.

:slightly_smiling_face:

if i add account name it is throwing error
image

I tried using the workflow that you had attached on Post 1 above, on my outlook. It works perfectly fine. Not able to replicate your issue.

Can you try setting this default value to the variable :

Trying out options to check why it is failing for you.

no luck bro still same error

Not sure what’s going wrong. Your workflow works perfectly fine for me. Tried a lot of combinations with that as well.
Okay, lets focus on the workaround for now. If you say if activity is the problem, then temporarily store the from address in a variable and then try to compare the address with the variable.