The string amplitude on surfaces with boundaries and crosscaps