It means that the object you are trying to use as username is empty, try to retrieve it beforehand to see wether the username is filled with an emailaddres.
Check if Email Message object is associated with Email Account with the debugger
Ideally, I would also expect an error being thrown if the email account is empty, because application cannot read a property from empty object
From your other statements, it also sounds like a permission issue. Check if the user from this module, has access to the association