How to create a task which run at cron time and send emails to users? Is there a module (based on cron) which can be used to check a date value form a field and to send email to users 2 days before the date? 

If there is not, how can I implement this to work with cron?
Here is how I did without using any custom modules. 

I implemented hook_cron like that:

function HOOK_cron() {
    // search for expiration date interval
    $result = db_query("SELECT my_date, uid, company_name, nid
            FROM my_table
            LEFT JOIN ...
            LEFT JOIN ...
            LEFT JOIN ...
            LEFT JOIN ...      
            WHERE my_date BETWEEN DATE(NOW( ) + INTERVAL 6 DAY ) AND DATE( NOW( ) + INTERVAL 20 DAY)")-&gt;fetchAll(PDO::FETCH_ASSOC);

    foreach ($result as $product) {
        $module = 'MY_MODULE';
        $key = 'MY_KEY';

        $from = 'my_email@test.com';

        $user_account = user_load($product['uid']);
        $product_detail = node_load($product['nid']);

        $to_user_mail = $user_account-&gt;mail;

        // build the email
        $message = drupal_mail($module, $key, $to_user_mail, LANGUAGE_NONE, array(), $from, FALSE);

        //$message['headers']['Content-Type'] = 'text/html; charset=UTF-8; format=flowed';
        $message['headers']['Cc'] = 'cc_email@test.com';
        $message['headers']['Reply-To'] = 'reply_to_email@test.com';

        $message['subject'] = 'THE SUBJECT';

        $message['body'] = array();
        $message['body'][] = 'Dear ' . $user_account-&gt;name;
        $message['body'][] = '...';
        $message['body'][] = 'Regards,';
        $message['body'][] = 'YOUR NAME';

        // retrieve the responsible implementation for this message.
        $system = drupal_mail_system($module, $key);

        // format the message body.
        $message = $system-&gt;format($message);

        // send e-mail
        $message['result'] = $system-&gt;mail($message);
    }
}