Upvote:7
Take the Beijing Subway Airport Express Line (北京地铁机场线). It goes right from Dongzhimen to PEK with only one stop in between.
There are two stations at PEK, one in Terminal 2 and one in Terminal 3. The Airport Express costs ¥25 per trip, for which you could either use a Beijing public transportation card or buy a single-trip ticket at a vending machine, located in the Dongzhimen station.