Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to send email by using odoo?

By
willie ho
on 8/19/15, 3:18 AM 528 views

I need to send email by a scheduler.

How do I do it when I have already set my email server?

0
Kalpana Hemnani
On 8/19/15, 9:32 AM

Hello willie ho,

If you want to send a static mail, can be directly sent by below steps:

def send_mail(self, cr, uid, context=None):

mail_body="""you can write any html tags and text here"""

mail_vals={

'email_from': email_from,

'email_to':email_to,

'subject': 'Subject',

'body_html': mail_body

}

mail = self.pool.get('mail.mail').create(cr, uid, mail_vals, context=context)

self.pool.get('mail.mail').send(cr, uid, [mail], context=context)

After creating a scheduler method you have to create a scheduler xml record:

<record forcecreate="True" id="ir_cron_scheduler_action" model="ir.cron">

<field name="name">Scheduler</field>

<field eval="True" name="active"/>

<field name="user_id" ref="base.user_root"/>

<field name="interval_number">1</field>

<field name="interval_type">days</field>

<field name="numbercall">-1</field>

<field eval="False" name="doall"/>

<field eval="'model.model'" name="model"/><!--model in which method of scheduler is defined -->

<field eval="'send_mail'" name="function"/>

<field eval="'(True,)'" name="args"/>

</record>

Hope this helps.

Let me know if you want to know solution for sending mail using template!

Thanks and Regards,

Kalpana Hemnani

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 8/19/15, 3:18 AM
Seen: 528 times
Last updated: 8/19/15, 9:32 AM