Just use the
--include parameter, like this:
grep -r -i --include \*.h --include \*.cpp CP_Image ~/path | mailx -s GREP email@example.com
that should do what you want.
To take the explanation from HoldOffHunger's answer below:
--include \*.cpp: all *.cpp: C++ files (escape with \ just in case you have a directory with asterisks in the filenames)
./: Start at current directory.