Dielectronic recombination from the ground and excited states of C4+ and O6+