Here is what the NEC says about this
250.140 Frames of Ranges and Clothes Dryers.
Frames of electric ranges, wall-mounted ovens, counter-mounted cooking units, clothes dryers, and outlet or junction boxes that are part of the circuit for these appliances shall be grounded in the manner specified by 250.134 or 250.138.
Exception: For existing branch circuit installations only where an equipment grounding conductor is not present in the outlet or junction box, the frames of electric ranges, wall-mounted ovens, counter-mounted cooking units, clothes dryers, and outlet or junction boxes that are part of the circuit for these appliances shall be permitted to be grounded to the grounded circuit conductor if all the following conditions are met.
(1) The supply circuit is 120/240-volt, single-phase, 3-wire; or 208Y/120-volt derived from a 3-phase, 4-wire, wye-connected system.
(2) The grounded conductor is not smaller than 10 AWG copper or 8 AWG aluminum.
(3) The grounded conductor is insulated, or the grounded conductor is uninsulated and part of a Type SE service-entrance cable and the branch circuit originates at the service equipment.
(4) Grounding contacts of receptacles furnished as part of the equipment are bonded to the equipment.
250.142 Use of Grounded Circuit Conductor for Grounding Equipment.
(A) Supply-Side Equipment. A grounded circuit conductor shall be permitted to ground non?current-carrying metal parts of equipment, raceways, and other enclosures at any of the following locations:
(1) On the supply side or within the enclosure of the ac service-disconnecting means
(2) On the supply side or within the enclosure of the main disconnecting means for separate buildings as provided in 250.32(B)
(3) On the supply side or within the enclosure of the main disconnecting means or overcurrent devices of a separately derived system where permitted by 250.30(A)(1)
(B) Load-Side Equipment. Except as permitted in 250.30(A)(1) and 250.32(B), a grounded circuit conductor shall not be used for grounding non?current-carrying metal parts of equipment on the load side of the service disconnecting means or on the load side of a separately derived system disconnecting means or the overcurrent devices for a separately derived system not having a main disconnecting means.
Exception No. 1: The frames of ranges, wall-mounted ovens, counter-mounted cooking units, and clothes dryers under the conditions permitted for existing installations by 250.140 shall be permitted to be grounded by a grounded circuit conductor.