Exemple #1
0
    def insert_communication(self, raw):
        email = Email(raw)

        communication = frappe.get_doc({
            "doctype": "Communication",
            "subject": email.subject,
            "content": email.content,
            "sent_or_received": "Received",
            "sender_full_name": email.from_real_name,
            "sender": email.from_email,
            "recipients": email.mail.get("To"),
            "email_account": self.name,
            "communication_medium": "Email"
        })

        self.set_thread(communication, email)

        communication.insert(ignore_permissions=1)

        # save attachments
        email.save_attachments_in_doc(communication)

        if self.enable_auto_reply and getattr(communication, "is_first",
                                              False):
            self.send_auto_reply(communication, email)

        # notify all participants of this thread
        # convert content to HTML - by default text parts of replies are used.
        communication.content = markdown2.markdown(communication.content)
        communication.notify(attachments=email.attachments,
                             except_recipient=True)
Exemple #2
0
	def insert_communication(self, raw):
		email = Email(raw)

		communication = frappe.get_doc({
			"doctype": "Communication",
			"subject": email.subject,
			"content": email.content,
			"sent_or_received": "Received",
			"sender_full_name": email.from_real_name,
			"sender": email.from_email,
			"recipients": email.mail.get("To"),
			"email_account": self.name,
			"communication_medium": "Email"
		})

		self.set_thread(communication, email)

		communication.insert(ignore_permissions = 1)

		# save attachments
		email.save_attachments_in_doc(communication)

		if self.enable_auto_reply and getattr(communication, "is_first", False):
			self.send_auto_reply(communication, email)

		# notify all participants of this thread
		# convert content to HTML - by default text parts of replies are used.
		communication.content = markdown2.markdown(communication.content)
		communication.notify(attachments=email.attachments, except_recipient = True)
	def insert_communication(self, raw,account_name):
		"""Create new doc of mailbox and append info retrived from email and the attachments against mailbox"""
		email = Email(raw)

		date = datetime.datetime.strptime(email.date,'%Y-%m-%d %H:%M:%S')
		final_recipients=self.make_listof_recipients(email.mail.get("To"))
		if email.mail.get("Cc"):
			final_cc=self.make_listof_recipients(email.mail.get("Cc"))
		else:
			final_cc=''
		mailbox = frappe.get_doc({
			"doctype": "Mailbox",
			"subject": email.subject,
			"content": email.content,
			"sender_full_name": email.from_real_name,
			"sender": email.from_email,
			"email_account": self.name,
			"user":self.user,
			"recipient": final_recipients,
			"recipients_name":account_name,
			"cc":final_cc,
			"date_time":date
		})

		#self.set_thread(communication, email)
		mailbox.insert(ignore_permissions = 1)

		# save attachments
		email.save_attachments_in_doc(mailbox)
		mailbox.check_contact_exists()
		mailbox.save()		
	def insert_communication(self, raw,account_name):
		"""Create new doc of mailbox and append info retrived from email and the attachments against mailbox"""
		email = Email(raw)

		date = datetime.datetime.strptime(email.date,'%Y-%m-%d %H:%M:%S')
		final_recipients=self.make_listof_recipients(email.mail.get("To"))
		if email.mail.get("Cc"):
			final_cc=self.make_listof_recipients(email.mail.get("Cc"))
		else:
			final_cc=''
		mailbox = frappe.get_doc({
			"doctype": "Mailbox",
			"subject": email.subject,
			"content": email.content,
			"sender_full_name": email.from_real_name,
			"sender": email.from_email,
			"email_account": self.name,
			"user":self.user,
			"recipient": final_recipients,
			"recipients_name":account_name,
			"cc":final_cc,
			"date_time":date
		})

		#self.set_thread(communication, email)
		mailbox.insert(ignore_permissions = 1)

		# save attachments
		email.save_attachments_in_doc(mailbox)
		mailbox.check_contact_exists()
		mailbox.save()		
Exemple #5
0
    def receive(self, test_mails=None):
        """Called by scheduler to receive emails from this EMail account using POP3."""
        if self.enable_incoming:
            if frappe.local.flags.in_test:
                incoming_mails = test_mails
            else:
                pop3 = self.get_pop3()
                incoming_mails = pop3.get_messages()

            for raw in incoming_mails:
                email = Email(raw)

                communication = frappe.get_doc({
                    "doctype":
                    "Communication",
                    "subject":
                    email.subject,
                    "content":
                    email.content,
                    "sent_or_received":
                    "Received",
                    "sender_full_name":
                    email.from_real_name,
                    "sender":
                    email.from_email,
                    "recipients":
                    email.mail.get("To"),
                    "email_account":
                    self.name,
                    "communication_medium":
                    "Email"
                })

                self.set_thread(communication, email)

                communication.insert(ignore_permissions=1)

                # save attachments
                email.save_attachments_in_doc(communication)

                if self.enable_auto_reply:
                    self.send_auto_reply(communication)

                # notify all participants of this thread
                # convert content to HTML - by default text parts of replies are used.
                communication.content = markdown2.markdown(
                    communication.content)
                communication.notify(communication.get_email(),
                                     except_sender=True)
	def insert_communication(self, raw):
		email = Email(raw)

		if email.from_email == self.email_id:
			# gmail shows sent emails in inbox
			# and we don't want emails sent by us to be pulled back into the system again
			raise SentEmailInInbox

		communication = frappe.get_doc({
			"doctype": "Communication",
			"subject": email.subject,
			"content": email.content,
			"sent_or_received": "Received",
			"sender_full_name": email.from_real_name,
			"sender": email.from_email,
			"recipients": email.mail.get("To"),
			"email_account": self.name,
			"communication_medium": "Email"
		})

		self.set_thread(communication, email)

		communication.insert(ignore_permissions = 1)

		# save attachments
		communication._attachments = email.save_attachments_in_doc(communication)

		if self.enable_auto_reply and getattr(communication, "is_first", False):
			self.send_auto_reply(communication, email)

		# notify all participants of this thread
		# convert content to HTML - by default text parts of replies are used.
		communication.content = markdown2.markdown(communication.content)

		return communication
	def insert_communication(self, raw):
		email = Email(raw)
		date = datetime.datetime.strptime(email.date,'%Y-%m-%d %H:%M:%S').strftime('%d-%m-%Y %H:%M:%S')
		communication = frappe.get_doc({
			"doctype": "Inbox",
			"subject": email.subject,
			"content": email.content,
			"sender_full_name": email.from_real_name,
			"from": email.from_email,
			"email_account": self.name,
			"user":self.user,
			"date_time":date
		})

		#self.set_thread(communication, email)

		communication.insert(ignore_permissions = 1)
		#communication.submit()

		# save attachments
		email.save_attachments_in_doc(communication)
Exemple #8
0
    def insert_communication(self, raw):
        email = Email(raw)

        if email.from_email == self.email_id:
            # gmail shows sent emails in inbox
            # and we don't want emails sent by us to be pulled back into the system again
            raise SentEmailInInbox

        communication = frappe.get_doc({
            "doctype": "Communication",
            "subject": email.subject,
            "content": email.content,
            "sent_or_received": "Received",
            "sender_full_name": email.from_real_name,
            "sender": email.from_email,
            "recipients": email.mail.get("To"),
            "cc": email.mail.get("CC"),
            "email_account": self.name,
            "communication_medium": "Email"
        })

        self.set_thread(communication, email)

        communication.flags.in_receive = True
        communication.insert(ignore_permissions=1)

        # save attachments
        communication._attachments = email.save_attachments_in_doc(
            communication)

        # replace inline images

        dirty = False
        for file in communication._attachments:
            if file.name in email.cid_map and email.cid_map[file.name]:
                dirty = True

                email.content = email.content.replace(
                    "cid:{0}".format(email.cid_map[file.name]), file.file_url)

        if dirty:
            # not sure if using save() will trigger anything
            communication.db_set("content", sanitize_html(email.content))

        # notify all participants of this thread
        if self.enable_auto_reply and getattr(communication, "is_first",
                                              False):
            self.send_auto_reply(communication, email)

        return communication
Exemple #9
0
	def insert_communication(self, raw):
		email = Email(raw)

		if email.from_email == self.email_id:
			# gmail shows sent emails in inbox
			# and we don't want emails sent by us to be pulled back into the system again
			raise SentEmailInInbox

		communication = frappe.get_doc({
			"doctype": "Communication",
			"subject": email.subject,
			"content": email.content,
			'text_content': email.text_content,
			"sent_or_received": "Received",
			"sender_full_name": email.from_real_name,
			"sender": email.from_email,
			"recipients": email.mail.get("To"),
			"cc": email.mail.get("CC"),
			"email_account": self.name,
			"communication_medium": "Email"
		})

		self.set_thread(communication, email)

		communication.flags.in_receive = True
		communication.insert(ignore_permissions = 1)

		# save attachments
		communication._attachments = email.save_attachments_in_doc(communication)

		# replace inline images


		dirty = False
		for file in communication._attachments:
			if file.name in email.cid_map and email.cid_map[file.name]:
				dirty = True

				email.content = email.content.replace("cid:{0}".format(email.cid_map[file.name]),
					file.file_url)

		if dirty:
			# not sure if using save() will trigger anything
			communication.db_set("content", sanitize_html(email.content))

		# notify all participants of this thread
		if self.enable_auto_reply and getattr(communication, "is_first", False):
			self.send_auto_reply(communication, email)

		return communication
	def insert_communication(self, raw):
		email = Email(raw)
		date = datetime.datetime.strptime(email.date,'%Y-%m-%d %H:%M:%S')
		
		communication = frappe.get_doc({
			"doctype": "Inbox",
			"subject": email.subject,
			"content": email.content,
			"sender_full_name": email.from_real_name,
			"sender": email.from_email,
			"email_account": self.name,
			"user":self.user,
			"recipients": email.mail.get("To"),
			"date_time":date
		})

		#self.set_thread(communication, email)

		communication.insert(ignore_permissions = 1)

		# save attachments
		email.save_attachments_in_doc(communication)
		communication.check_contact_exists()
		communication.save()
Exemple #11
0
    def insert_communication(self, raw):
        email = Email(raw)

        if email.from_email == self.email_id:
            # gmail shows sent emails in inbox
            # and we don't want emails sent by us to be pulled back into the system again
            raise SentEmailInInbox

        communication = frappe.get_doc({
            "doctype": "Communication",
            "subject": email.subject,
            "content": email.content,
            "sent_or_received": "Received",
            "sender_full_name": email.from_real_name,
            "sender": email.from_email,
            "recipients": email.mail.get("To"),
            "cc": email.mail.get("CC"),
            "email_account": self.name,
            "communication_medium": "Email"
        })

        self.set_thread(communication, email)

        communication.insert(ignore_permissions=1)

        # save attachments
        communication._attachments = email.save_attachments_in_doc(
            communication)

        if self.enable_auto_reply and getattr(communication, "is_first",
                                              False):
            self.send_auto_reply(communication, email)

        # notify all participants of this thread
        # convert content to HTML - by default text parts of replies are used.
        communication.content = markdown2.markdown(communication.content)

        return communication