<commit_before>import win32com.client
olx = win32com.client.gencache.EnsureDispatch("outlook.application")
mapi = olx.GetNamespace("MAPI")
home_folder = mapi.Folders['mine'].Folders['Inbox'].Folders['0_trash_sifter']

CONSTS = {'SMTP_ADDRESS':"http://schemas.microsoft.com/mapi/proptag/0x39FE001E", \
    'ADDRESS_TYPE':"http://schemas.microsoft.com/mapi/proptag/0x39050003"}

with open(r'C:\users\drumschl\desktop\hoobadooba.txt','w') as f:
    for j in home_folder.Items:
        ignore_var = f.write('====NEW-ITEM====\n')
        try:
            sender = j.Sender
            if sender.Type=='EX':
                ignore_var = f.write('From: {}\n'.format(j.Sender.PropertyAccessor.GetProperty(CONSTS['SMTP_ADDRESS'])))
            elif sender.Type=='SMTP':
                ignore_var = f.write('From: {}\n'.format(j.SenderEmailAddress))
        except Exception as e:
            ignore_var = f.write('From: NO_CLUE_MAN\nERROR!! ERROR!!\n===============\n{}\n===============\n\n'.format(e))
        to_list = []
        cc_list = []
        try:
            for i in j.Recipients:
                if i.Type==1:
                    to_list.append(i.PropertyAccessor.GetProperty(CONSTS['SMTP_ADDRESS']))
                elif i.Type==2:
                    cc_list.append(i.PropertyAccessor.GetProperty(CONSTS['SMTP_ADDRESS']))
            ignore_var = f.write('To: {}\n'.format('; '.join(to_list)))
            ignore_var = f.write('CC: {}\n'.format('; '.join(cc_list)))
        except Exception as e:
            ignore_var = f.write('To: NO_CLUE_MAN\nCC: NO_CLUE_MAN\nERROR!! ERROR!!\n===============\n{}\n===============\n\n'.format(e))
        try:
            ignore_var = f.write('Sent: {}\n'.format(j.SentOn.strftime("%Y-%m-%d %H:%M:%S")))
        except Exception as e:
            ignore_var = f.write('Sent: NO_CLUE_MAN\nERROR!! ERROR!!\n===============\n{}\n===============\n\n'.format(e))
        try:
            ignore_var = f.write('Recd: {}\n'.format(j.ReceivedTime.strftime("%Y-%m-%d %H:%M:%S")))
        except Exception as e:
            ignore_var = f.write('Recd: NO_CLUE_MAN\nERROR!! ERROR!!\n===============\n{}\n===============\n\n'.format(e))
        try:
            ignore_var = f.write('Subject: {}\n'.format(j.Subject))
        except Exception as e:
            ignore_var = f.write('Subject: NO_CLUE_MAN\nERROR!! ERROR!!\n===============\n{}\n===============\n\n'.format(e))
        try:
            ignore_var = f.write('{}\n'.format(j.Body))
        except Exception as e:
            ignore_var = f.write('NO_CLUE_MAN\nERROR!! ERROR!!\n===============\n{}\n===============\n\n'.format(e))
<commit_msg>Update email-to-txt.py<commit_after>import win32com.client
olx = win32com.client.gencache.EnsureDispatch("outlook.application")
mapi = olx.GetNamespace("MAPI")
home_folder = mapi.Folders['mine'].Folders['Inbox'].Folders['0_trash_sifter']

CONSTS = {'SMTP_ADDRESS':"http://schemas.microsoft.com/mapi/proptag/0x39FE001E", \
    'ADDRESS_TYPE':"http://schemas.microsoft.com/mapi/proptag/0x39050003"}

with open(r'path\hoobadooba.txt','w') as f:
    for j in home_folder.Items:
        ignore_var = f.write('====NEW-ITEM====\n')
        try:
            sender = j.Sender
            if sender.Type=='EX':
                ignore_var = f.write('From: {}\n'.format(j.Sender.PropertyAccessor.GetProperty(CONSTS['SMTP_ADDRESS'])))
            elif sender.Type=='SMTP':
                ignore_var = f.write('From: {}\n'.format(j.SenderEmailAddress))
        except Exception as e:
            ignore_var = f.write('From: NO_CLUE_MAN\nERROR!! ERROR!!\n===============\n{}\n===============\n\n'.format(e))
        to_list = []
        cc_list = []
        try:
            for i in j.Recipients:
                if i.Type==1:
                    to_list.append(i.PropertyAccessor.GetProperty(CONSTS['SMTP_ADDRESS']))
                elif i.Type==2:
                    cc_list.append(i.PropertyAccessor.GetProperty(CONSTS['SMTP_ADDRESS']))
            ignore_var = f.write('To: {}\n'.format('; '.join(to_list)))
            ignore_var = f.write('CC: {}\n'.format('; '.join(cc_list)))
        except Exception as e:
            ignore_var = f.write('To: NO_CLUE_MAN\nCC: NO_CLUE_MAN\nERROR!! ERROR!!\n===============\n{}\n===============\n\n'.format(e))
        try:
            ignore_var = f.write('Sent: {}\n'.format(j.SentOn.strftime("%Y-%m-%d %H:%M:%S")))
        except Exception as e:
            ignore_var = f.write('Sent: NO_CLUE_MAN\nERROR!! ERROR!!\n===============\n{}\n===============\n\n'.format(e))
        try:
            ignore_var = f.write('Recd: {}\n'.format(j.ReceivedTime.strftime("%Y-%m-%d %H:%M:%S")))
        except Exception as e:
            ignore_var = f.write('Recd: NO_CLUE_MAN\nERROR!! ERROR!!\n===============\n{}\n===============\n\n'.format(e))
        try:
            ignore_var = f.write('Subject: {}\n'.format(j.Subject))
        except Exception as e:
            ignore_var = f.write('Subject: NO_CLUE_MAN\nERROR!! ERROR!!\n===============\n{}\n===============\n\n'.format(e))
        try:
            ignore_var = f.write('{}\n'.format(j.Body))
        except Exception as e:
            ignore_var = f.write('NO_CLUE_MAN\nERROR!! ERROR!!\n===============\n{}\n===============\n\n'.format(e))

{'fraction_non_alphanumeric': 0.24078297225389586, 'fraction_numerical': 0.008361839604713038, 'mean_word_length': 2.7273371104815864, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5805478', 'n_tokens_mistral': 1844, 'n_tokens_neox': 1752, 'n_words': 241}