mega+cmos camera+sim900 gsm module

am working on a project that will detect the presence in an intruder,snap the person using cmos camera,save the image into mega2560's 256k flash memory and send the picture as mms to a smartphone.
please i need help on the codes.