I want to send a file from odoo to my personal email(for testing).
And I'm using this code ,which runs fine:
tools.email_send(email_from='sending@test.fr',
email_to=['recive@gmail.com'],
subject='Some subject',
body='hello')
So I recive 'hello' and there is not problem of connection.
But it's impossible to attache a file to this method.
Here is my file, and I don't know how to send it with my message:
att_id = self.env['ir.attachment'].create({
'name': 'My name',
'type': 'binary',
'datas':excel_file,
'datas_fname': 'Myname.xsl',
'res_model': 'print.invoice..cron',
'res_id': self.id,
'mimetype': 'text/csv'
})
att_id contains the id of attachment