def __read_mails_and_write(self, data): """ Reads a mail, let Mailparser parse the mail, write to outputfile @param data: string contains a maildir email """ timestamp, output, note, properties = \ MailParser.parse_message(data) self._writer.write_org_subitem(timestamp, output, note, properties)
def __read_mails_and_write(self, data): """ Read All mails, let Mailparser parse each mail, write to outputfile @param data: string containing all mails of mbox-file """ message = data.split("Message-ID:") for mail in message: if not (mail == message[0]): timestamp, output, note, properties = \ MailParser.parse_message(mail) self._writer.write_org_subitem(timestamp, output, note, properties)
def __read_news_and_write(self, data): """ Read All newsgroup entries, let Mailparser parse each newsgroup entry, write to outputfile @param data: string containing all mails of mbox-file """ message = data.split("X-Mozilla-Status: 0001" + "\n" + "X-Mozilla-Status2:" + " 00000000" + "\n" + "Path:") for news in message: if not (news == message[0]): timestamp, output, note, properties = \ MailParser.parse_message(news) self._writer.write_org_subitem(timestamp, output, note, properties)
def __fetch_mails_and_write(self, server, message_ids, folder_name): """ Fetches All headers, let Mailparser parse each mail, write to outputfile @param server: imaplib IMAP4_SLL object @param message_ids: list of ids to fetch @param folder_name: folder name of connection """ num = ",".join(message_ids) logging.debug(num) typ, data = server.uid("fetch", num, "(BODY.PEEK[HEADER.FIELDS " + \ "(Date Subject " + \ "From To Cc Reply-To Message-ID)])") if typ == "OK": i = 0 # we have to go in step 2 because every second string is a ")" for i in range(0, len(data), 2): message = data[i][1] timestamp, output, note, properties = \ MailParser.parse_message(message) # just for debbuging in orgfile # properties.add("NUM",data[i][0][:5]) self._writer.write_org_subitem(timestamp, output, note, properties) else: logging.error("Could not fetch mails typ - %s", typ) server.logout(1) sys.exit(1)