how to send email?

how to send email when i click on the button?

الصورة الرمزية
2 الإجابات
Umashankar Subramani
Best Answer

Hi aneesh,


1.Create a template for your email ,settings->email->template-> create -> Name-User defined, Applies to- description to model, model- model for creating email, and you can give acces rights, on the content tab you need create the template. In email configuration you need to configure your email address for sender and receiver. And in advanced setting you have an option that you can add a attachment automatically by giving the optional report to print or attach and save the template.

2.You need to create the button with type="object", which the respective method where you have to configure your email.

3.In your model , you need get the template for eg 

        email= self.pool.get('email.template'),uid,[('model_id.model', '=','')]) 

so using this template you need to compose the email and return        

       ir_model_data = self.pool.get('')
            compose_form_id = ir_model_data.get_object_reference(cr, uid, 'mail', 'email_compose_message_wizard_form')[1]
        except ValueError:
            compose_form_id = False 
        ctx = dict(context)
                'default_model': '',
                'default_res_id': ids[0],
                'default_use_template': bool(template_id),
                'default_template_id': template_id[0],
                'default_composition_mode': 'comment',
                'mark_so_as_sent': True

       return {
                'type': 'ir.actions.act_window',
                'view_type': 'form',
                'view_mode': 'form',
                'res_model': 'mail.compose.message',
                'views': [(compose_form_id, 'form')],
                'view_id': compose_form_id,
                'target': 'new',
                'context': ctx,

Try this.........

الصورة الرمزية