Casimir effect in the presence of external fields