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

i want to send a mail through template in my own module

By
Ranjith
on 7/4/16, 9:46 AM 266 views

this is my code:



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

email_template_obj = self.pool.get('email.template')

template_ids = email_template_obj.search(cr, uid, [('model_id.model', '=', 'sales_order')], context=context)

print template_ids

if template_ids:

values = email_template_obj.generate_email(cr, uid, template_ids[0], ids[0], context=context)

"""values['subject'] = subject

values['email_to'] = inian@rcktechiees.com

values['body_html'] = body_html

values['body'] = body_html"""

values['res_id'] = False

mail_mail_obj = self.pool.get('mail.mail')

msg_id = mail_mail_obj.create(cr, uid, values, context=context)

if msg_id:

mail_mail_obj.send(cr, uid, [msg_id], context=context)

return True




sender = 'ranjith'

receivers = 'inian'

message = """hai

"""

smtpObj = smtplib.SMTP(host='smtp.gmail.com', port=587)

smtpObj.ehlo()

smtpObj.starttls()

smtpObj.ehlo()

smtpObj.login(user="ranjith@rcktechiees.com", password="ranjith6795")

smtpObj.sendmail(sender, receivers, message)

print "Successfully sent email"




sender = str(self.from_id)

receiver = str(self.email_id)

message = str(self.leave_reason)

try:

smtpObj = smtplib.SMTP(host='smtp.gmail.com', port=587)

smtpObj.ehlo()

smtpObj.starttls()

smtpObj.ehlo()

username = str(self.from_id)

pwd = str(self.mail_password)

smtpObj.login(user="ranjith@rcktechiees", password="*******")

smtpObj.sendmail(sender, receiver, message)

smtpObj.quit()

self.state = 'waiting'

print "success"

except SMTPException:

print "error"



no error in this code but no response for sending a mail // what should i have to do for it ? please any one help me to rectify my problem ,

thanks all

0
ayman mohammed adam
On 7/10/16, 8:39 AM

hello please check this link i think it help you

http://findnerd.com/list/view/How-to-send-mail-in-next-level-in-workflow-in-OpenERPOdoo-8/21369/


0
ANHLQ
On 7/7/16, 4:38 AM

After send email please go to Settings/Technical/Email/Emails to check your email status.

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: 7/4/16, 9:46 AM
Seen: 266 times
Last updated: 7/10/16, 8:39 AM