Verification theorems for stochastic optimal control problems in Hilbert spaces by means of a generalized Dynkin formula