Two imidazole derivatives, 2‐(2‐((benzo[d]thiazol‐2‐ylthio)methyl)‐4,5‐dihydro‐1H‐imidazol‐1‐yl)ethan‐1‐ol (BTM) and 2‐(2‐((1H‐benzo[d][1,2,3]triazol‐1‐yl)methyl)‐4,5‐dihydro‐1H‐imidazol‐1‐yl)ethan‐1‐ol (BTMS), as a new corrosion inhibitor were synthesized, and their inhibition behaviors for mild steel contained in emulsion were investigated by gravimetric experiment, electrochemical tests, and theoretical calculations. The results show that the inhibition effect of BTMS is better than that of BTM, the maximum value of the inhibition efficiency reaches 97.9%. The resultant adsorption films from BTM/BTMS adsorbed on mild steel, effectively inhibiting the corrosion of mild steel is mainly through chemisorption and follow to Langmuir's adsorption isotherm.