I am getting error while reading outlook email "Object reference not set to an instance of an object "

While reading outlook mail message using Get Outlook MailMessage activity i am getting error message "Object reference not set to an instance of an object "

can some one help me?

1 Like

@pankajs3

This error usually occurs when we are trying to assign Null value. Please check that expression in Assign activity once.

@lakshman
Can you please tell me how to assign “System.Collection.Generic.List” of “System.Net.Mail.MailMessage” .

@pankajs3

Get Outlook Mail Message activity will give you output as list of mail messages. Please check once.

@lakshman
As you can see that i am doing Get Outlook Mail Message activity to get the output as list of mail message. But after that i am getting this error.

@lakshman
As you can see that i am doing Get Outlook Mail Message activity to get the output as list of mail message. But after that i am getting this error. I am getting count of MailMessage but while shorting those email by DateTime, i am getting this error.

image

image

the objects you are using to sort the email, some of them are null…

@bcorrea
How can we resolve this issue while getting null. please help in this critical error.

we cant see what you are using in your orderby… if you have like this:
emails.OrderBy(Function(x) DateTime.Parse(x.Headers(“Date”).ToString)).ToList
and still have the error, then in debug, check the headers and if they have date inside…

Hello,
Did you find a solution? Currently running into the same issue and exploring the possibility of a GPO preventing programmatic access to Outlook, because the same automation workflow runs perfectly in an environment without said GPO.

In case anyone is struggling with this issue, where you are certain there is not a problem with your workflow, check out the Registry settings. Image is from the list UiPath support provided. Their suggestion fixed the issue in our end.

1 Like

Hi @fernando321, so we need to have all policies listed in snapshot in order to fix this issue?

In my case yes - we had to update all of them.

The same happened to me and when I looked into the mailbox, there was an AutoRecall mail. AutoRecall mails will not have Date header and so it was not able sort the collection.

Fix: I have moved the auto recall mail to Junk Mail folder and then the issue has been fixed.