Getting error "Object reference not setto instance of an object.This error usually occurs when using a variable with no set value(not initialized)
Please make sure that the mail variable contains something. It looks like it has no value.
Yes, I saw that. Have you checked what is in ‘row’?
I had the same error too. But have now managed to get it working.
Here’s what i did.
- Currently using the downgraded Mail package - version 1.1.6361.22988 instead of the latest.
- Put my If then else within a Try Catch
- Didnt need to define ‘mail’ variable which is the individual email retrieved from the list of emails (I used variable “emails”. The variable type is Systems.Collections.Generic.List<System.Net.Mail.MailMessages>
- I’d used “mail.From.Address.ToString” when writing to log file.
- I’d used "mail.From.Address.Contains(“abc.com”) in the IF condition
- In the Catch section of try-catch i put handling for NullReferenceException. However i noticed it never went into the Catch section anymore
- I’d tried this with Outlook and IMAP.