We demonstrate a versatile method for injecting metallic elements into an electron-beam ion trap using a metal vapor source. This method is based on the evaporation of a metal target by continuous electron-beam impact. We present visible emission spectra of highly charged tungsten ions prepared by the present injection scheme. By comparison with the conventional injection method using a high-vapor-pressure W(CO)6 compound, several advantages of the present method, i.e. suppressing charge exchange reactions in the trap region and quick recovery of the vacuum condition after stopping the injection, are found. The present injection method also facilitates the measurement of emission spectra of highly charged niobium ions, which have never previously been observed using electron-beam ion traps.