Пример #1
0
def send_comm_email(d, name, sent_via=None, print_html=None, attachments='[]', send_me_a_copy=False):
	from json import loads
	footer = None

	if sent_via:
		if hasattr(sent_via, "get_sender"):
			d.sender = sent_via.get_sender(d) or d.sender
		if hasattr(sent_via, "get_subject"):
			d.subject = sent_via.get_subject(d)
		if hasattr(sent_via, "get_content"):
			d.content = sent_via.get_content(d)
			
		footer = set_portal_link(sent_via, d)
		
	from webnotes.utils.email_lib.smtp import get_email
	mail = get_email(d.recipients, sender=d.sender, subject=d.subject, 
		msg=d.content, footer=footer)
	
	if send_me_a_copy:
		mail.cc.append(webnotes.conn.get_value("Profile", webnotes.session.user, "email"))
	
	if print_html:
		print_html = scrub_urls(print_html)
		mail.add_attachment(name.replace(' ','').replace('/','-') + '.html', print_html)

	for a in loads(attachments):
		try:
			mail.attach_file(a)
		except IOError, e:
			webnotes.msgprint("""Unable to find attachment %s. Please resend without attaching this file.""" % a,
				raise_exception=True)
Пример #2
0
def get_formatted_html(subject, message, footer=None):
	message = scrub_urls(message)

	return inline_css(webnotes.get_template("templates/emails/standard.html").render({
		"content": message,
		"footer": get_footer(footer),
		"title": subject
	}))
Пример #3
0
	def set_html(self, message, text_content = None, footer=None):
		"""Attach message in the html portion of multipart/alternative"""
		message = message + self.get_footer(footer)
		message = scrub_urls(message)

		# this is the first html part of a multi-part message, 
		# convert to text well
		if not self.html_set:
			if text_content:
				self.set_text(text_content)
			else:
				self.set_html_as_text(message)
		
		self.set_part_html(message)
		self.html_set = True
Пример #4
0
    def set_html(self, message, text_content=None, footer=None):
        """Attach message in the html portion of multipart/alternative"""
        message = message + self.get_footer(footer)
        message = scrub_urls(message)

        # this is the first html part of a multi-part message,
        # convert to text well
        if not self.html_set:
            if text_content:
                self.set_text(text_content)
            else:
                self.set_html_as_text(message)

        self.set_part_html(message)
        self.html_set = True
Пример #5
0
def send_comm_email(d,
                    name,
                    sent_via=None,
                    print_html=None,
                    attachments='[]',
                    send_me_a_copy=False):
    from json import loads
    footer = None

    if sent_via:
        if hasattr(sent_via, "get_sender"):
            d.sender = sent_via.get_sender(d) or d.sender
        if hasattr(sent_via, "get_subject"):
            d.subject = sent_via.get_subject(d)
        if hasattr(sent_via, "get_content"):
            d.content = sent_via.get_content(d)

        footer = set_portal_link(sent_via, d)

    from webnotes.utils.email_lib.smtp import get_email
    mail = get_email(d.recipients,
                     sender=d.sender,
                     subject=d.subject,
                     msg=d.content,
                     footer=footer)

    if send_me_a_copy:
        mail.cc.append(
            webnotes.conn.get_value("Profile", webnotes.session.user, "email"))

    if print_html:
        print_html = scrub_urls(print_html)
        mail.add_attachment(
            name.replace(' ', '').replace('/', '-') + '.html', print_html)

    for a in loads(attachments):
        try:
            mail.attach_file(a)
        except IOError, e:
            webnotes.msgprint(
                """Unable to find attachment %s. Please resend without attaching this file."""
                % a,
                raise_exception=True)