In Magento 1.4, I am successfully using this code to mark an order as Complete and add a shipping tracking code to it :
$order = Mage::getModel(\'sales/order\')-
if($shipment){ if(!$shipment->getEmailSent()){ $shipment->sendEmail(true); $shipment->setEmailSent(true); $shipment->save(); } }