• The function is now working, though I  did have to specify the master database - it did not find xp_sendmail via "db_applications". 

    I am having trouble capturing the return code values (boolean) and/or result sets (from Books Online: Result Sets: xp_sendmail returns this message: "Mail sent").   I would like to return both.  I used your same code and I get an error at .execute: