Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import imaplib
- import email
- def getVenmoPaymentDetails():
- #setup the email port and give permission details
- mail = imaplib.IMAP4_SSL('imap.gmail.com')
- mail.login('YOURPROXYEMAIL@gmail.com', 'passwordToProxyEmail')
- mail.list()
- mail.select('inbox')
- #combs through inbox folders for the latest email
- result, data = mail.uid('search', None, "ALL")
- i = len(data[0].split())
- for x in range(i):
- latest_email_uid = data[0].split()[x]
- result, email_data = mail.uid('fetch', latest_email_uid, '(RFC822)')
- raw_email = email_data[0][1]
- #decoding
- raw_email_string = raw_email.decode('utf-8')
- email_message = email.message_from_string(raw_email_string)
- for part in email_message.walk():
- if part.get_content_type() == "text/plain": # ignore attachments/html
- body = part.get_payload(decode=True)
- body = str((body.decode('utf-8')))
- relevantPaymentInfo = []
- #GET DOLLAR VALUE OF PAYMENT
- paymentLine = ((body.split("\n"))[7]).split("$")
- relevantPaymentInfo.append(float(paymentLine[1]))
- #GET SENDERS NAME
- senderLine = ((body.split("\n"))[2]).split("<")
- relevantPaymentInfo.append(senderLine[0])
- #GET DATE OF PAYMENT
- dateLine = ((body.split("\n"))[7]).split("ยท")
- relevantPaymentInfo.append(dateLine[0])
- return relevantPaymentInfo
Add Comment
Please, Sign In to add comment