Milk contains immunomodulatory compounds that may be important to protect the immature intestine in preterm neonates from harmful inflammatory reactions involved in disorders like necrotising enterocolitis (NEC). We hypothesised that bovine colostrum and milk formulas enriched with sialic acids (SL), gangliosides (Gang) or osteopontin (OPN) would improve gastrointestinal function and NEC resistance in preterm neonates. Forty-seven caesarean-delivered preterm pigs were given total parenteral nutrition for 2 d followed by 1·5 d of enteral feeding. In Expt 1, a control formula was compared with an OPN-enriched formula (n 13), while Expt 2 compared a control formula with bovine colostrum or formulas enriched with Gang or SL (n 4–6). OPN enrichment decreased NEC severity relative to control formula (P < 0·01), without any significant effects on NEC incidence, digestive enzyme activities and hexose absorption. Neither SL- nor Gang-enriched formulas improved NEC resistance or digestive functions, while all the intestinal functional parameters were significantly improved in pigs fed bovine colostrum, relative to formula. The effects in vivo were supported in vitro by bacteria- and dose-dependent modulation by colostrum whey of the cytokine response from bacteria-stimulated murine bone marrow-derived dendritic cells (DC). In conclusion, OPN had only moderate NEC-protective effects, while formulas enriched with Gang or SL were ineffective. The observed modulation of DC cytokine response by bovine colostrum whey in vitro may be due to a synergistic action of various milk bioactives, and it may explain its beneficial effects on NEC development and intestinal function in a piglet model of preterm infants.