The growing share of fluctuating renewable electricity production within the German energy system causes the increasing necessity for flexible consumers, producers, and storage technologies to balance supply and demand. District heating networks with combined heat and power units, Power-to-Heat applications, and thermal energy storage capacities can serve as one of these flexible options. In this context, a simulation model of the district heating network of the rural community Dollnstein, Germany, was built. With the residual load of different regional areas (Germany, Bavaria, Eichstätt, Dollnstein) it is investigated, how the heat generators can operate in an electricity market beneficial way. Two different control algorithms were evaluated: Due to a correlation between the residual loads and the CO2 emissions of the electricity mix, the CO2 savings achieved by this control algorithm are determined. Another way to operate electricity market beneficial is to consider the current CO2 emissions of each region. The main outcomes of this paper are, that there is a high potential for sector coupling by shifting the operation times of a CHP and a heat pump according to the residual load. The electricity demand of the heat pump can be met in terms of low CO2 emissions of the electricity mix, while the CHP can replace electricity with high CO2 emissions. These results can be improved, by considering not the residual load but the current CO2 emissions in the control algorithm. [ABSTRACT FROM AUTHOR]