Missions towards the boundaries of the Solar System require long transfer times and advanced propulsion systems. An interesting option is offered by electric sails, a new propulsion concept that uses the solar wind dynamic pressure for generating a continuous thrust without the need for reaction mass. The aim of this paper is to investigate the performance of such a propulsion system for obtaining escape conditions from the Solar System and planning a mission to reach the heliosphere boundaries. The problem is studied in an optimal framework, by minimizing the time to reach a given solar distance or a given hyperbolic excess speed. Depending on the value of the sail characteristic acceleration, it is possible that, in an initial mission phase, the sailcraft may approach the Sun to exploit the increased available thrust due to the growing solar wind electron density. The corresponding optimal trajectory is constrained to not pass inside a heliocentric sphere whose admissible radius is established by thermal constraints. Once the escape condition is met, the sail is jettisoned and the payload alone continues its journey without any propulsion system. A medium performance electric sail is shown to have the potentialities to reach the heliosheath, at a distance of 100 AU, in about fifteen years. Finally, the Interstellar Heliopause Probe mission is used as a reference mission to further quantify the electric sail capabilities for an optimal transfer towards the heliopause nose (200 AU).