Guest User

Untitled

a guest
Mar 19th, 2018
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. import imaplib
  2. import email
  3.  
  4. def getVenmoPaymentDetails():
  5. #setup the email port and give permission details
  6. mail = imaplib.IMAP4_SSL('imap.gmail.com')
  7. mail.login('YOURPROXYEMAIL@gmail.com', 'passwordToProxyEmail')
  8. mail.list()
  9. mail.select('inbox')
  10.  
  11. #combs through inbox folders for the latest email
  12. result, data = mail.uid('search', None, "ALL")
  13. i = len(data[0].split())
  14. for x in range(i):
  15. latest_email_uid = data[0].split()[x]
  16. result, email_data = mail.uid('fetch', latest_email_uid, '(RFC822)')
  17. raw_email = email_data[0][1]
  18.  
  19. #decoding
  20. raw_email_string = raw_email.decode('utf-8')
  21. email_message = email.message_from_string(raw_email_string)
  22. for part in email_message.walk():
  23. if part.get_content_type() == "text/plain": # ignore attachments/html
  24. body = part.get_payload(decode=True)
  25. body = str((body.decode('utf-8')))
  26. relevantPaymentInfo = []
  27.  
  28. #GET DOLLAR VALUE OF PAYMENT
  29. paymentLine = ((body.split("\n"))[7]).split("$")
  30. relevantPaymentInfo.append(float(paymentLine[1]))
  31.  
  32. #GET SENDERS NAME
  33. senderLine = ((body.split("\n"))[2]).split("<")
  34. relevantPaymentInfo.append(senderLine[0])
  35.  
  36. #GET DATE OF PAYMENT
  37. dateLine = ((body.split("\n"))[7]).split("ยท")
  38. relevantPaymentInfo.append(dateLine[0])
  39.  
  40. return relevantPaymentInfo
Add Comment
Please, Sign In to add comment