CBs email function is as follows.
Code:
/**
* Mail function (uses phpMailer or SMTP depending on global settings)
*
* @param string $from From e-mail address
* @param string $fromname From name
* @param string|array $recipient Recipient e-mail address(es)
* @param string $subject E-mail subject
* @param string $body Message body
* @param int $mode false = plain text, true = HTML
* @param string|array $cc CC e-mail address(es)
* @param string|array $bcc BCC e-mail address(es)
* @param string|array $attachment Attachment file name(s) (array index is filename, if string)
* @param string|array $replyto ReplyTo e-mail address(es)
* @param string|array $replytoname ReplyTo name(s)
* @param array $properties properties to apply to the mailer object before processing and sending (useful for supplying custom mailer)
* @param null|string $error stores most recent mailer error if available
* @return bool True: mail sent, False: mail not sent (error)
*/
function comprofilerMail( $from, $fromname, $recipient, $subject, $body, $mode = 0, $cc = null, $bcc = null, $attachment = null, $replyto = null, $replytoname = null, $properties = array(), &$error = null )
This handles the entire process of sending the email and all you'll need to do is supply the necessary parameters in the PHP of your code action. You can of course use Joomla API as well if you're more comfortable with Joomla API.