I recently had to obtain a new key for my 2004 316 TI Here is the instructions to programme new keys
Keys must be programmed in pairs, any programming of a new key will automatically disable any existing keys.
1 Insert new key into ignition and turn to Accessory position
2 remove key and within 10 seconds hold down unlock (arrow button) and press lock button 3 times.
3 if this has been successful car will lock and unlock in quick succession.
4 repeat operation for 2nd key but it is not necessary on this occasion to insert key into ignition.