Skip to Content
Menu
This question has been flagged
4 Replies
18772 Views

Hello, 

I would like send an email with python,

I try to complete the table named mail.compose.message.res.partner.rel

But it's Many2many relation.

How can i do ?

I try this :

mail_rel = self.env['mail.compose.message.res.partner.rel']

mail_values_rel = {

'wizard_id': mail.id,

'partner_id': '8' ,

}

mail_mail_obj_rel = mail_rel.create(mail_values_rel)


But my partner_ids isn't fixed. Idon't know how i can have his id.  

Avatar
Discard
Best Answer

coco,

For send a mail through code,

First you need to create a new record for "mail.mail" object with your respective values like:

mail_pool = self.env['mail.mail']

values={}

values.update({'subject': 'Your subject'})

values.update({'email_to': 'To email'})

values.update({'body_html': 'body' })

values.update({'body': 'body' })

values.update({'res_id': 'obj.id' }) #[optional] here is the record id, where you want to post that email after sending

values.update({'model': ''Object Name }) #[optional] here is the object(like 'project.project')  to whose record id you want to post that email after sending

msg_id = mail_pool.create(values)

# And then call send function of the mail.mail,

if msg_id:

mail_pool.send([msg_id])

Hope it Helps you

Avatar
Discard
Author

ok i do this but i don't receive email :(

did u configured, outgoing mail server?

Author

it's good now :D thanks !

worked for me,thank you

Best Answer

You could use the method described here to do the same using the email.template model

https://www.odoo.com/forum/help-1/question/correct-way-to-e-mail-custom-html-record-in-function-96570#answer_97108

Avatar
Discard
Related Posts Replies Views Activity
1
Mar 15
8034
5
May 25
17132
0
Apr 25
732
1
Apr 25
961
0
Mar 25
922