Changeset View
Changeset View
Standalone View
Standalone View
pykolab/xml/event.py
Show First 20 Lines • Show All 1,267 Lines • ▼ Show 20 Lines | def to_message_itip(self, from_address, method="REQUEST", participant_status="ACCEPTED", subject=None, message_text=None): | ||||
from email.MIMEBase import MIMEBase | from email.MIMEBase import MIMEBase | ||||
from email.MIMEText import MIMEText | from email.MIMEText import MIMEText | ||||
from email.Utils import COMMASPACE, formatdate | from email.Utils import COMMASPACE, formatdate | ||||
# encode unicode strings with quoted-printable | # encode unicode strings with quoted-printable | ||||
from email import charset | from email import charset | ||||
charset.add_charset('utf-8', charset.SHORTEST, charset.QP) | charset.add_charset('utf-8', charset.SHORTEST, charset.QP) | ||||
msg = MIMEMultipart() | msg = MIMEMultipart("alternative") | ||||
msg_from = None | msg_from = None | ||||
attendees = None | attendees = None | ||||
if method == "REPLY": | if method == "REPLY": | ||||
# TODO: Make user friendly name <email> | # TODO: Make user friendly name <email> | ||||
msg['To'] = self.get_organizer().email() | msg['To'] = self.get_organizer().email() | ||||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | def to_message_itip(self, from_address, method="REQUEST", participant_status="ACCEPTED", subject=None, message_text=None): | ||||
msg.attach(MIMEText(utils.stripped_message(message_text), _charset='utf-8')) | msg.attach(MIMEText(utils.stripped_message(message_text), _charset='utf-8')) | ||||
part = MIMEBase('text', 'calendar', charset='UTF-8', method=method) | part = MIMEBase('text', 'calendar', charset='UTF-8', method=method) | ||||
del part['MIME-Version'] # mime parts don't need this | del part['MIME-Version'] # mime parts don't need this | ||||
part.set_payload(self.as_string_itip(method=method)) | part.set_payload(self.as_string_itip(method=method)) | ||||
part.add_header('Content-Disposition', 'attachment; filename="event.ics"') | |||||
part.add_header('Content-Transfer-Encoding', '8bit') | part.add_header('Content-Transfer-Encoding', '8bit') | ||||
msg.attach(part) | msg.attach(part) | ||||
# restore the original list of attendees | # restore the original list of attendees | ||||
# attendees being reduced to the replying attendee above | # attendees being reduced to the replying attendee above | ||||
if attendees is not None: | if attendees is not None: | ||||
self._attendees = attendees | self._attendees = attendees | ||||
▲ Show 20 Lines • Show All 148 Lines • Show Last 20 Lines |