Skip to content

Instantly share code, notes, and snippets.

@montarion
Created November 10, 2016 13:23
Show Gist options
  • Save montarion/4d492fa4b5be6d7a8cc44ac39df5b5b7 to your computer and use it in GitHub Desktop.
Save montarion/4d492fa4b5be6d7a8cc44ac39df5b5b7 to your computer and use it in GitHub Desktop.
alsjeblieft kiet
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