In this paper, optimal energy management of interconnected multi-smart apartment buildings considering energy flow among them is presented. It is considered that each smart apartment building includes various equipment such as combined heat and power (CHP) generator, battery storage system, thermal storage system and smart appliances. To assess the effects of power exchange capability among the multiple-smart apartment buildings, two case studies are evaluated with and without considering mentioned capability. It can be found that the operation cost of the interconnected multi-smart apartment buildings by considering the effects of power exchange capability among smart apartment buildings under control and management of a home energy management system is decreased. The proposed model is formulated as mixed-integer programming (MIP) which guarantees the global optimum solution, and it is solved by General Algebraic Modeling System (GAMS) optimization software.