def on_communication(self, comm): if webnotes.conn.get_value("Profile", extract_email_id(comm.sender), "user_type")=="System User": status = "Replied" else: status = "Open" webnotes.conn.set(self.doc, 'status', status)
def __init__(self, content): import email, email.utils import datetime # print 'content start' # print content # print 'content end' self.mail = email.message_from_string(content) self.text_content = '' self.html_content = '' self.attachments = [] self.parse() self.set_content_and_type() self.set_subject() self.from_email = extract_email_id(self.mail["From"]) self.from_real_name = email.utils.parseaddr(self.mail["From"])[0] if self.mail["Date"]: utc = time.mktime(email.utils.parsedate(self.mail["Date"])) utc_dt = datetime.datetime.utcfromtimestamp(utc) self.date = convert_utc_to_user_timezone(utc_dt).strftime('%Y-%m-%d %H:%M:%S') else: self.date = now()
def on_communication(self, comm): if comm.sender == self.get_sender(comm) or \ webnotes.conn.get_value("Profile", extract_email_id(comm.sender), "user_type")=="System User": self.doc.status = "Waiting for Customer" else: self.doc.status = "Open" self.update_status() self.doc.save()
def execute(): email_lead = {} for name, email in webnotes.conn.sql("""select name, email_id from `tabLead` where ifnull(email_id, '')!='' order by creation asc"""): email = extract_email_id(email) if email: if email not in email_lead: email_lead[email] = name else: webnotes.rename_doc("Lead", name, email_lead[email], force=True, merge=True)
def _validate(email): """validate an email field""" if email: if "," in email: email = email.split(",")[-1] if not validate_email_add(email): # try extracting the email part and set as sender new_email = extract_email_id(email) if not (new_email and validate_email_add(new_email)): webnotes.msgprint("%s is not a valid email id" % email, raise_exception = 1) email = new_email return email
def _validate(email): """validate an email field""" if email: if "," in email: email = email.split(",")[-1] if not validate_email_add(email): # try extracting the email part and set as sender new_email = extract_email_id(email) if not (new_email and validate_email_add(new_email)): webnotes.msgprint("%s is not a valid email id" % email, raise_exception=1) email = new_email return email
def __init__(self, content): """ Parse the incoming mail content """ import email from email.utils import parseaddr self.mail = email.message_from_string(content) self.text_content = '' self.html_content = '' self.attachments = [] self.parse() self.set_content_and_type() self.from_email = extract_email_id(self.mail["From"]) self.from_real_name = parseaddr(self.mail["From"])[0]
def __init__(self, content): import email import email.utils import datetime self.mail = email.message_from_string(content) self.text_content = '' self.html_content = '' self.attachments = [] self.parse() self.set_content_and_type() self.from_email = extract_email_id(self.mail["From"]) self.from_real_name = email.utils.parseaddr(self.mail["From"])[0] utc = email.utils.mktime_tz(email.utils.parsedate_tz(self.mail["Date"])) utc_dt = datetime.datetime.utcfromtimestamp(utc) self.date = convert_utc_to_user_timezone(utc_dt).strftime('%Y-%m-%d %H:%M:%S')
def __init__(self, content): import email, email.utils import datetime self.mail = email.message_from_string(content) self.text_content = '' self.html_content = '' self.attachments = [] self.parse() self.set_content_and_type() self.set_subject() self.from_email = extract_email_id(self.mail["From"]) self.from_real_name = email.utils.parseaddr(self.mail["From"])[0] utc = email.utils.mktime_tz(email.utils.parsedate_tz(self.mail["Date"])) utc_dt = datetime.datetime.utcfromtimestamp(utc) self.date = convert_utc_to_user_timezone(utc_dt).strftime('%Y-%m-%d %H:%M:%S')
def execute(): from webnotes.utils import extract_email_id for name, recipients in webnotes.conn.sql("""select name, recipient_list from `tabEmail Digest`"""): recipients = "\n".join([extract_email_id(r) for r in recipients.split("\n")]) webnotes.conn.set_value("Email Digest", name, "recipient_list", recipients)