If you've already tried a Factory Reset on your HTC One M8 and it hasn't solved your problem, the next step might be a Hard Reset. A Hard Reset is basically the same as a Factory Reset but you do it manually with the hardware buttons. You also have a little more control over what gets deleted.
First of all you need to first make sure Fastboot is disabled in Settings > Power.
With your HTC One M8 switched off, hold down the Volume Down button and press Power until you see the screen with three Androids at the bottom. If you just want to do a Factory Reset with the hardware buttons you can do it on this screen. Using the Volume buttons, scroll down to Factory Reset and use the Power button to confirm. This will Factory Reset the device.