How to create email notification function in Odoo?
<p>I have <code>calender.event</code> module. In that I have one date field <code>ending_date</code>. I wanted to create function when ending date exceeds current date it should send notification to all employees.</p>

<p>This function at calender.event inherited file</p>

<pre><code>def send_birthday_email(self, cr, uid, ids=None, context=None):
        sobj = self.pool.get('calendar.event').browse(cr,uid,ids,context=context)
            ir_model_data = self.pool.get('ir.model.data')
            template_obj = self.pool.get('email.template')
            cc_text = ''
            if sobj.attendee_ids:
                    for cc_obj in sobj.attendee_ids:
                        if cc_obj.email:
                                cc_text += cc_obj.email + ','
                    for rec in sobj:
                            template_id = ir_model_data.get_object_reference(cr,uid,'calander_extended', 'calendar_notify')[1]
                    self.pool.get('email.template').write(cr,uid,template_id,{'email_to' : cc_text,})
                    self.pool.get('email.template').send_mail(cr,uid,template_id,rec.id,force_send=True,context=context)
                    return True 
</code></pre>

<p>This is email template written for it </p>

<pre><code>&lt;?xml version="1.0"?&gt;
&lt;openerp&gt;
    &lt;data&gt;
        &lt;record id="calendar_notify" model="email.template"&gt;
            &lt;field name="name"&gt;Email Notification&lt;/field&gt;
            &lt;field name="email_from"&gt;${object.event_id.user_id.email or ''}&lt;/field&gt;
            &lt;field name="subject"&gt;${object.event_id.name}&lt;/field&gt;
            &lt;field name="model_id" ref="calander_extended.model_calendar_event"/&gt;
        &lt;field name="email_to" &gt;${('' if object.partner_id and object.partner_id.email and object.partner_id.email==object.email else object.email|safe)}&lt;/field&gt;
        &lt;field name="partner_to"&gt;${object.partner_id and object.partner_id.email and object.partner_id.email==object.email and object.partner_id.id or False }&lt;/field&gt;
            &lt;field name="auto_delete" eval="True"/&gt;

            &lt;field name="body_html"&gt;&lt;![CDATA[
                &lt;html&gt;
                    &lt;head&gt;
                        &lt;meta http-equiv="Content-type" content="text/html; charset=utf-8" /&gt;
                        &lt;title&gt;${object.event_id.name}&lt;/title&gt;
                        &lt;style&gt; 
                            span.oe_mail_footer_access {
                                display:block;    
                                text-align:center;
                                color:grey;                                
                            }
                        &lt;/style&gt;
                    &lt;/head&gt;
                    &lt;body&gt;
                        &lt;div style="border-radius: 2px; max-width: 1200px; height: auto;margin-left: auto;margin-right: auto;background-color:#f9f9f9;"&gt;
                            &lt;div style="height:auto;text-align: center;font-size : 30px;color: #8A89BA;"&gt;
                                &lt;strong&gt;${object.event_id.name}&lt;/strong&gt;
                            &lt;/div&gt;

                        &lt;/div&gt;
                    &lt;/body&gt;
                &lt;/html&gt;
                ]]&gt;
                &lt;/field&gt;
        &lt;/record&gt;
    &lt;/data&gt;
&lt;/openerp&gt;
</code></pre>

<p>When i invoke that function by clicking button then its not getting any error .but no getting mail also to attendees</p>