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

odoo 9, Automatically send email when I submited a form??

By
sama
on 11/7/16, 3:16 AM 128 views

via Automated Action, server Action, mail template , Is it possible??

5

Hilar AK

--Hilar AK--
829
| 5 2 7
Italy
--Hilar AK--


Hilar AK
On 11/8/16, 12:45 AM

HI,
If you need to send email when the form submits,
try in your controller where the action is routed
ie form action="/xxx"
try

@http.route("/xxx", auth='public')
def send_mail_on_action_submit(self,**post):
#get the values and perform actions from post
     mail_obj.send() or use send_mail() function
0

zbik

--zbik--
5976
| 6 4 7
Lodz, Poland
--zbik--


zbik
On 11/7/16, 9:25 AM

You'll find a similar examples in this post: How to send an email after login?

and in this:  How to send an email via python with the new API ?

0
shameem@aχoncoms
On 11/7/16, 5:47 AM

Yes Sama it is possible. See the python code

Example

import smtplib

sender = 'username'
receivers = 'destinations'
message = """hai         """

smtpObj = smtplib.SMTP(host='smtp.gmail.com', port=587) 
smtpObj.ehlo()
smtpObj.starttls()
smtpObj.ehlo()
smtpObj.login(user="username", password="password") 
smtpObj.sendmail(sender, receivers, message
print "Successfully sent email

All the best !

thanks, I do not know this method, via the user interface if you can explain to me that, for example,in email template form, How to set our fields(from , to ,..)????

sama
on 11/7/16, 6:17 AM

Suppose source is foo@gmail.com and destination is bar@gmail.com

Then

sender = 'foo@gmail.com' # you can use sender = self.field_name

receivers = 'bar@gmail.com'

...

...

smtpObj.login(user="foo@gmail.com", password="password of foo@gmail.com")

...

shameem@aχoncoms
on 11/8/16, 1:00 AM

You can use html template

body = fields.Html('Body')

refer : http://stackoverflow.com/questions/882712/sending-html-email-using-python#answer-882770

shameem@aχoncoms
on 11/8/16, 1:05 AM

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: 11/7/16, 3:16 AM
Seen: 128 times
Last updated: 11/11/16, 5:36 AM