FedEx Corp. reported fiscal fourth quarter profit that beat expectations as an e-commerce boom boosts package deliveries and a manufacturing rebound drives growing demand in its freight-hauling business.

FedEx and other package delivery companies have benefited from online shopping that surged 17 percent in 2017 as consumers increasingly opted for the convenience of having goods shipped directly to their homes. FedEx has invested heavily to keep up with the flood of demand by automating its operations, and those investments are beginning to pay off.

For its fiscal fourth quarter, FedEx reported adjusted earnings per share of $5.91, compared with $4.19 a year earlier. Analysts had predicted $5.69. Revenue was $17.3 billion, compared with analysts’ expectations of $17.2 billion.

The company forecast earnings of $17 to $17.60 a share for the fiscal year through next May, excluding pension adjustments and costs from the integration of TNT Express. The midpoint of the forecast is lower than the average $17.48 estimate of analysts surveyed by Bloomberg, but would represent a 13 percent gain on adjusted earnings for the year that ended May 31, Memphis, Tennessee-based FedEx said in a statement Tuesday.

The company expects revenue to rise 9 percent for the coming year, while analysts had predicted a 6 percent gain. The operating margin is forecast to be 8.5 percent excluding TNT Express integration costs. That would be up from a comparable margin of 7.8 percent in fiscal year 2018 that was recast because of pension accounting changes, FedEx said.

Industrial freight is also rebounding, with the added bonus of rising cargo prices as trucking companies struggle to find enough drivers. Rates for less-than-truckload business, the category where FedEx competes, are expected to rise 13 percent this year, according to freight forecaster FTR Transportation Intelligence.

The company expects capital spending to be $5.6 billion, down by $100 million from fiscal year 2018. That spending will “spike” after this year, mostly at the company’s Express unit, said Chief Financial Officer Alan Graf on a conference call with analysts. The company announced an order for 24 cargo aircraft from Boeing Co. for the unit, worth $6.6 billion at list prices.

The overall costs to integrate TNT Express, a European package delivery company that FedEx acquired two years ago, are now estimated to be $1.5 billion, about $100 million more than expected. TNT’s sales force should be fully integrated within a year, the company said.

FedEx has risen 3.5 percent this year, compared to a 3.3 percent rise in the S&P. Shares were little changed at $258.49 after the close of regular trading in New York.