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

email
activities
variable

#1


Getting error "Object reference not setto instance of an object.This error usually occurs when using a variable with no set value(not initialized)
#2

Please make sure that the mail variable contains something. It looks like it has no value.


#3


Terminal get feild error
#4

Yes, I saw that. Have you checked what is in ‘row’?


#5

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.

#6

thx all