First create a shell script that sends an email tailored to your needs,
e.g.,
#! /usr/local/bin/tcsh -f
mail paciorek << -end-
Finished executing MCMC run with output $1 and $2 iterations.
-end-
Save this file, e.g. as mail.csh, and make sure it is executable using
>chmod guo+x mail.csh. Next, in your C++ program, call the
script, including the two arguments used by the script
string cmd="source mail.csh ";
cmd=cmd+output_file+" "+num_its;
system(cmd.c_str());
Note that num_its here would need to be a string, so you would have to convert from an integer to a string for this approach to work.