Created
November 11, 2016 08:17
-
-
Save montarion/a03f5576a78917824f7a2ef28a896704 to your computer and use it in GitHub Desktop.
niet dat k iets veranderd heb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import getpass, poplib | |
import csv | |
def verwijderen(anu): | |
outfile = open("plaatsen2.csv", "w") | |
outfile.close() | |
infile = open("gebied.csv", "r") | |
file = infile.readlines() | |
plaatsen = len(file) | |
infile.close() | |
infile = open("gebied.csv", "r") | |
clock = 0 | |
while clock < plaatsen: | |
line = (infile.readline()) | |
if anu not in line: | |
outfile = open("plaatsen2.csv", "a") | |
outfile.write(line) | |
outfile.close() | |
clock = clock + 1 | |
infile = open("gebied.csv", "w") | |
infile.close() | |
infile = open("plaatsen2.csv", "r") | |
file = infile.readlines() | |
plaatsen = len(file) | |
infile.close() | |
infile = open("plaatsen2.csv", "r") | |
clock = 0 | |
while clock < plaatsen: | |
line = (infile.readline()) | |
outfile = open("gebied.csv", "a") | |
outfile.write(line) | |
outfile.close() | |
clock = clock + 1 | |
#user = input('my_user_name') | |
Mailbox = poplib.POP3_SSL('pop.googlemail.com', '995') | |
Mailbox.user('[email protected]') | |
Mailbox.pass_('Hondenbijeenkomst') | |
numMessages = len(Mailbox.list()[1]) | |
mailbestand = open('lastemail.txt', 'w') | |
for i in range(numMessages): | |
for msg in Mailbox.retr(i+1)[1]: | |
#print(msg) | |
mailbestand.write(str(msg)) | |
Mailbox.quit() | |
mailbestand = open('lastemail.txt', 'r') | |
item = mailbestand.read() | |
gesplit = str(item).split("b'") | |
print(gesplit) | |
if "uit'" in gesplit: | |
print("uit") | |
Path = (gesplit[6]) | |
Path = Path.strip("Return-Path: <") | |
email = Path.strip(">'") | |
verwijderen(email) | |
elif "in'" in gesplit: | |
print("in") | |
with open("gebied.csv", "a", newline = "") as CSVFile: | |
writer = csv.writer(CSVFile, delimiter = ";") | |
Path = (gesplit[6]) | |
Path = Path.strip("Return-Path: <") | |
email = Path.strip(">'") | |
print(email) | |
gebied = "in" | |
writer.writerow((email, gebied)) | |
mailbestand.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment