I reading outlook emails using “Get Outlook Email Message” then sorting them by date(emails.OrderBy(Function(x) DateTime.Parse(x.Headers(“Date”).ToString)).ToList)
getting this error.
Object reference not set to an instance of an object.
I reading outlook emails using “Get Outlook Email Message” then sorting them by date(emails.OrderBy(Function(x) DateTime.Parse(x.Headers(“Date”).ToString)).ToList)
getting this error.
Object reference not set to an instance of an object.
Silly question but, did you check if emails
is not null before doing the sorting?
That error is returned when trying to do something with a null/empty variable
@nerlichman
I have checked the mail count it giving me 24 emails. but while shorting the email based on receiving date generating error.
Can help me in this question?
Did you try checking that Headers("Date")
is returning data?
Also, try assing that (without the .ToList
) to a variable of type Object. If the error doesn’t ocurr, it may be that the .OrderBy
is not returning results, so the .ToList
won’t work.
That error is telling you that you can’t do what you are trying with an empty variable.