Q:

Code Igniter Custom Helper

I am new to Code igniter / OOP but trying to figure this out.
I am trying to make a helper that I can use in my code; this is what it looks like:
if ( ! function_exists('email'))
{
    function email($type, $to, $subject, $object)
    {
        switch($type){

            case 'new':

                $body = "Hello ". $object['FirstName'] . ' ' . $object['LastName'] . ","
                    . "<p/><p/>Thank you.";
                break;
        }

        // Send it
        $this->load->library('email');
        $this->email->to($to);
        $this->email->from('blah@website.com', 'James');
        $this->email->subject($subject);
        $this->email->message($body);
        $this->email->send();

    }
}

I then include it in the autoload for the helper section.
When i try to access it within my controller, I get an error.
$obect['FirstName']='Carl';
$obect['LastName']='Blah';
email('new', 'test@website.com', 'test', $object);

Here is the error that I am getting:
Fatal error: Using $this when not in object context in C:\inetpub\wwwroot\attrition\application\helpers\email_helper.php on line 17 

A:

Using $this when not in object context

This simply means you can not use the $this keyword outside of an object(class), 
as @Kryten pointed out.
Helpers are generally only used for embedding in html, such as formatting data.
<p><?php echo formatHelper(escape($var)); ?></p>

What you need to do is read up a little on creating a Library.

