Getting error "Object reference not set to an instance of an object." while using sender of email

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.

  1. Currently using the downgraded Mail package - version 1.1.6361.22988 instead of the latest.
  2. Put my If then else within a Try Catch
  3. 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>
  4. I’d used “mail.From.Address.ToString” when writing to log file.
  5. I’d used "mail.From.Address.Contains(“abc.com”) in the IF condition
  6. In the Catch section of try-catch i put handling for NullReferenceException. However i noticed it never went into the Catch section anymore :slight_smile:
  7. I’d tried this with Outlook and IMAP.
1 Like

thx all