Esempio n. 1
0
def run():
    dataDir = "Data/"
    #ExStart: LoadMsgFiles
    # Create an instance of MapiMessage from file
    msg = MapiMessage.from_file(dataDir +
                                "CreatingAndSavingOutlookMessages_out.msg")

    # Get subject
    print("Subject: " + msg.subject)

    # Get from address
    print("From: " + msg.sender_email_address)

    # Get body
    print("Body: " + msg.body)

    # Get recipients information
    print("Recipients Count: " + str(len(msg.recipients)))

    # Get Attachments information
    print("Attachments Count:" + str(len(msg.attachments)))

    # Print attachments information
    for index, att in enumerate(msg.attachments):
        if att.object_data is not None:
            print(att.display_name)
def run():

    dataDir = "Data/"
    #ExStart: GetMapiProperty
    # Load from file
    msg = MapiMessage.from_file(dataDir + "message.msg")

    # Access the MapiPropertyTag.PR_SUBJECT property
    prop = msg.properties[MapiPropertyTag.SUBJECT]

    # If the property is not found, check the MapiPropertyTag.PR_SUBJECT_W (which is a // Unicode peer of the MapiPropertyTag.PR_SUBJECT)
    if prop is None:
        prop = msg.properties[MapiPropertyTag.SUBJECT_W]

    # Cannot found
    if prop is None:
        print("No property found!")

    # Get the property data as string
    subject = prop.get_string()

    print("Subject:" + subject)
    # Read internet code page property
    prop = msg.properties[MapiPropertyTag.INTERNET_CPID]
    if prop is not None:
        print("CodePage:" + str(prop.get_long()))
def run():
	dataDir = "Data/"
	#ExStart: AddingVotingButtonToExistingMessage
	message = MapiMessage.from_file("message.msg")

	FollowUpManager.add_voting_button(message, "Indeed!")

	message.save(dataDir + "AddVotingButtonToExistingMessage_out.msg")
Esempio n. 4
0
def run():
    dataDir = "Data/"
    #ExStart: ReadingOnlyVotingButtons
    message = MapiMessage.from_file(dataDir + "MessageWithVotingResponded.msg")

    buttons = FollowUpManager.get_voting_buttons(message)

    for button in buttons:
        print(button)
def run():
	dataDir = "Data/"
	#ExStart: AddMessagesToPSTFiles
	pst = PersonalStorage.create(dataDir + "AddMessagesToPst_out.pst", FileFormatVersion.UNICODE)

	# Add new folder "Inbox"
	inboxFolder = pst.root_folder.add_sub_folder("Inbox");

	# Add message to Inbox Folder
	inboxFolder.add_message(MapiMessage.from_file(dataDir + "MapiMsgWithPoll.msg"))

	pst.dispose()
Esempio n. 6
0
def run():

	dataDir = "Data/"
	#ExStart: ReadingVotingOptions
	message = MapiMessage.from_file(dataDir + "MessageWithVotingResponded.msg")

	# This method can be useful when except voting buttons it is necessary to get other parameters (ex. a category)
	options = FollowUpManager.get_options(message)

	# Voting buttons will be introduced as a string with semi-column as a separator
	votingButtons = options.voting_buttons

	print(votingButtons)
def run():

    dataDir = "Data/"
    #ExStart: RenderingContactInformationToMhtml
    msg = MapiMessage.from_file(dataDir + "Contact.msg")
    op = MailConversionOptions()
    eml = msg.to_mail_message(op)

    #Prepare the MHT format options
    mhtSaveOptions = MhtSaveOptions()
    mhtSaveOptions.check_body_content_encoding = True
    mhtSaveOptions.preserve_original_boundaries = True
    formatOp = MhtFormatOptions.WRITE_HEADER | MhtFormatOptions.RENDER_VCARD_INFO
    mhtSaveOptions.rendered_contact_fields = ContactFieldsSet.NAME_INFO | ContactFieldsSet.PERSONAL_INFO | ContactFieldsSet.TELEPHONES | ContactFieldsSet.EVENTS
    mhtSaveOptions.mht_format_options = formatOp
    eml.save(dataDir + "RenderingContactInformationToMhtml_out.mhtml",
             mhtSaveOptions)
Esempio n. 8
0
def run():

    dataDir = "Data/"
    #ExStart: ReadVoteResultsInformation
    msg = MapiMessage.from_file(dataDir +
                                "AddVotingButtonToExistingMessage.msg")
    for recipient in msg.recipients:
        print("Recipient: {0}".format(recipient.display_name))

        #get the PR_RECIPIENT_AUTORESPONSE_PROP_RESPONSE property
        print("Response: {0}".format(recipient.properties[
            MapiPropertyTag.RECIPIENT_AUTORESPONSE_PROP_RESPONSE].get_string())
              )

        #Get the PR_RECIPIENT_TRACKSTATUS_TIME property
        mt = recipient.properties[MapiPropertyTag.RECIPIENT_TRACKSTATUS_TIME]
        if mt is not None:
            mt_value = mt.get_date_time()
            print("Response time: {}".format(mt_value))
Esempio n. 9
0
def run():
    dataDir = "Data/"
    #ExStart: DeleteVotingButtonFromMessage
    message = MapiMessage.from_file("message.msg")

    FollowUpManager.add_voting_button(message, "Indeed!")

    message.save(dataDir + "AddVotingButtonToExistingMessage_out.msg")

    eml = MailMessage("*****@*****.**", "*****@*****.**", "Subject", "Body")
    eml.is_draft = False
    msg = MapiMessage.from_mail_message(eml)

    options = FollowUpOptions()
    options.voting_buttons = "Yes;No;Maybe;Exactly!"
    FollowUpManager.set_options(msg, options)
    msg.save(dataDir + "MapiMsgWithPoll.msg")
    FollowUpManager.remove_voting_button(msg, "Exactly!")
    #Deleting a single button OR
    FollowUpManager.clear_voting_buttons(
        msg)  # Deleting all buttons from a MapiMessage
    msg.save(dataDir + "MapiMsgWithPoll_out.msg")
Esempio n. 10
0
def run():
    dataDir = "Data/"
    #ExStart: ReadingMapiNote
    note = MapiMessage.from_file(dataDir + "CreateAndSaveOutlookNote_out.msg")
    note2 = note.to_mapi_message_item()
Esempio n. 11
0
def run():
	dataDir = "Data/"
	#ExStart: DisplayReceipientsStatusFromMeetingReqeust
	message = MapiMessage.from_file(dataDir + "filename.msg")
	for recipient in message.recipients:
		print(recipient.recipient_track_status)
Esempio n. 12
0
def main():
    start_time = time.time()

    NrMails = int(17404)
    SavePer = int(40)

    random.seed(8370, version=1)
    rnlist = list()

    Traininglist = pd.DataFrame(columns=['TL1', 'TL2', 'TL3', 'TL4', 'TL5'],
                                index=range(1, 100))

    os.chdir('C:\\Documents\\Test6 Random incl text files')

    Indexlist = pd.read_csv('Index.csv', sep=";", header=None, index_col=0)

    for i in range(1, NrMails + 1):
        if i < 17302:
            msg = MapiMessage.from_file("ENRON (" + str(i) + ").msg")
            sep2 = "EDRM Enron Email Data Set has been produced in"
            msg = msg.body.split(sep2, 1)[0]
            msg = msg.replace('\n', ' ').replace('\r', ' ')

            msg = msg.lower().split(' ')

            for m in range(0, len(msg)):
                for n in set(msg[m]):
                    if ord(n) > 122:
                        msg[m] = msg[m].replace(n, '')
                    elif ord(n) < 97:
                        msg[m] = msg[m].replace(n, '')
            uniqWords = sorted(set(msg))
            uniqWords.remove('')
        else:
            uniqWords = 'test'
        if len(uniqWords) > 0:
            rnlist.append(i)

    for j in ['TL1', 'TL2', 'TL3', 'TL4', 'TL5']:
        for i in range(1, 1625):
            rnumber = random.choice(rnlist)
            Traininglist.at[i, j] = rnumber
            rnlist.remove(rnumber)

    Traininglist.to_csv('TraininglistENRON', sep='\t')

    del i, j, rnumber, rnlist

    start_time2 = time.time()
    Freq = pd.DataFrame(columns=['Index_given'])
    for l in list(Traininglist.columns.values):
        k = 1
        for i in list(Traininglist[l]):
            if i < 17302:
                msg = MapiMessage.from_file("ENRON (" + str(i) + ").msg")

                sep2 = "EDRM Enron Email Data Set has been produced in"
                msg = msg.body.split(sep2, 1)[0]
                msg = msg.replace('\n', ' ').replace('\r', ' ')

                msg = msg.lower().split(' ')

                for m in range(0, len(msg)):
                    for n in set(msg[m]):
                        if ord(n) > 122:
                            msg[m] = msg[m].replace(n, '')
                        elif ord(n) < 97:
                            msg[m] = msg[m].replace(n, '')
                uniqWords = sorted(set(msg))
                uniqWords.remove('')
                df = pd.DataFrame(columns=uniqWords)
                for word in uniqWords:
                    df.at[0, word] = msg.count(word)
            else:
                msg = list()
                with open("ENRON (" + str(i) + ").txt", 'r') as f:
                    lines = f.readlines()
                    for line in lines:
                        line = line.lower().replace('\n',
                                                    ' ').replace('\r',
                                                                 ' ').split()
                        for m in range(0, len(line)):
                            for n in set(line[m]):
                                if ord(n) > 122:
                                    line[m] = line[m].replace(n, '')
                                elif ord(n) < 97:
                                    line[m] = line[m].replace(n, '')
                        for word in line:
                            msg.append(word)
                uniqWords = sorted(set(msg))
                df = pd.DataFrame(columns=uniqWords)
                for word in uniqWords:
                    df.at[0, word] = msg.count(word)

            Freq = Freq.append(df, ignore_index=True)
            if '' in Freq.columns:
                del Freq['']

            j = (k - 1) % SavePer
            Freq.loc[j, 'Index_given'] = Indexlist.loc[i][1]
            if k % SavePer == 0:
                Freq.to_csv('FrequenciesENRON' + l + '-' + str(k), sep='\t')
                Freq = pd.DataFrame(columns=['Index_given'])
                Freq = Freq.take(list())
            k = k + 1
        Freq.to_csv('FrequenciesENRON' + l + '-1640', sep='\t')
        Freq = pd.DataFrame(columns=['Index_given'])
        Freq = Freq.take(list())

    Timings = pd.DataFrame(columns=['Description', 'time'])
    Timings = Timings.append(pd.Series({
        'Description': 'Script',
        'time': time.time() - start_time
    }),
                             ignore_index=True)
    Timings = Timings.append(pd.Series({
        'Description': 'Traininglist',
        'time': time.time() - start_time2
    }),
                             ignore_index=True)
    Timings.to_csv('TimingsENRON-Setup', sep='\t')
def run():
	dataDir = "Data/"
	#ExStart: LoadingContactFromMSG
	message = MapiMessage.from_file(dataDir + "Contact.msg")

	apiContact = message.to_mapi_message_item()