Chosen Solution
Suddenly I got electric shocks from my new iMac. Happened this first time Update (09/04/2019) I have already carried out the two tests you mentioned. No fault was found. Plus the Imac was the only electrical equipment on in the room. There was no other machine it could have come from?
Check your power outlets wiring and ground service! Make sure you’ve got a 3 pronged outlet and it’s properly wired. Using a multimeter to check an AC wall Outlet or use a simple outlet tester. Once you know your outlet is correctly wired test the system cord in the same way. Then when you plug the cord use your DVM to check the ground point of the outlet and the other on the systems metal body do you see voltage then? If your desk is conductive (metal) you might want to check it. Remove any electrical device other than the iMac (disconnect the other devices on the back of the iMac as well) to see if something else is shorted to ground and leaking to the iMac.
Seems there is conflicting advice as to what might be the cause. 1. static 2. GROUNDWORK electricity supply issues 3. Sockets not earthed correctly. Or it could be the machine is at fault because the aluminium casing is more likely to conduct electricity.