It is essential to investigate the evolution from a prestellar core to a protostar to understand the diversity of the protostellar mass. Some recent observations have shown that the dense matter outside a prestellar core can supply mass to the core. The dense core survey in the Orion Nebula Cluster region implies that the mass of prestellar cores is too small to reproduce the stellar mass distribution. Thus, it is crucial to investigate the environmental effects of the ambient medium outside a prestellar core on the protostellar mass growth in the star formation process. Ignoring both the magnetic field and cloud rotation, we calculate the evolution of star-forming cores with different outer envelope densities and gravitational radii. Our past study showed that the mass accretion rate is temporarily enhanced when the outer envelope density is high. We also indicated that the enhanced mass accretion rate could be explained by Bondi accretion. The density distribution outside a prestellar core contributes greatly to the protostellar mass. The prestellar outflow is also important to determine the protostellar mass and the star formation efficiency. In this study, with the magnetic field and cloud rotation, we calculate the evolution of star-forming cores with different outer envelope densities. We adopt star-forming cores composed of two parts: a centrally condensed core and an outer envelope. The inner condensed core has a critical Bonnor-Ebert density distribution and is enclosed by the outer envelope. We show that the mass accretion rate is temporarily enhanced when the outer envelope density is high, similar to the case without the magnetic field and cloud rotation. We discuss the effect of the density distribution outside a prestellar core on the outflow driving.