def inline(self): count = self.request.get('count') to = self.request.get('to') id = self.request.get('id') email = EmailModel().get_by_id(int(id)) attachment = email.attachments attachments = [] if attachment: list = attachment.split(",") for id in list: image = ImageModel.get_by_id(int(id)) if image: attachments.append((image.title + ".png", image.content)) params = dict(sender=email.send_from, to=to, subject=email.subject, body=email.message, html=email.message ) if attachments: params['attachment'] = attachments statistic = EmailStatisticModel() statistic.count = int(count) statistic.send_to = to statistic.subject = email.subject try: mail.send_mail(**params) statistic.status = "OK" except Exception, e: logging.error(e) statistic.status = "Fail %s from: %s to: %s" % (str(e), email.send_from, to)