NullReferenceException - Outlook mail messages

outlook
studio

#1

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)


#2

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.


#3

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


#4

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


#5

yes @kaderms


#6

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


#7

still same error


#8

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:


#9

if i add account name it is throwing error
image


#10

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.


#11

no luck bro still same error


#12

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.