This question has been flagged

Hello everyone,

here i want to check a lead type is 'lead' or 'opportunity' , and type is lead means send a mail,

here is my code,

    def _check_lead(self, cr, uid, ids, fields, args, context=None):
            for lead in self.browse(cr, uid, ids):

                if lead.type == 'lead':

                    sender = 'demo1@demo.com'
                    receivers = ['demo@demo.com']

                    message = """From: Administrator Test <administrator@demo.com>
                    To: To Person <demo@demo.com>
                    Subject: SMTP e-mail test

                    This is a test e-mail message.
                    """

                    try:
                       smtpObj = smtplib.SMTP('mail.demo.com',25)
                       smtpObj.login("administrator@demo.com", "password")
                       smtpObj.sendmail(sender, receivers, message)         
                    except SMTPException:
                       raise osv.except_osv(('Your mail was not send, because the Server connection was problem.'))
        return

 

Avatar
Discard