If you find a cheap solenoid valve (here's one from Amazon ...
that valve is designed for 1Mpa maximum pressure (about 150psi.) CO2 cartridges (and tanks) tend to be pressurized to beyond the triple-point pressure of about 900psi, so you really need a valve rated for at least 1000psi. That's probably enough to make it hard to find AND expensive (most values are for < 100psi pneumatic control systems.)
Plus you some sort of piercing mechanism.
(I guess if you only need ~100psi, it might be easier to put a pressure regulator upstream of the valve...)