def respose(choice): if choice == '1': print("enter recipient:- ") recipient = input() subject = input("Enter subject:-") text = input("Enter your message(should be 1 liner):- ") #for i in range(0,len(recipients)): # recipient=str(recipients[i]) ezgmail.send(recipient, subject, text) if choice == '2': unread = ezgmail.unread() #get subject and date results = ezgmail.summary(unread) #print the email print(str(unread[0].messages[0])) if choice == '3': #searching gSearch = input("what you want to search:-") search_result = ezgmail.search(gSearch) print(len(search_result)) results = ezgmail.summary(search_result) if choice == '4': #downloadinng gSearch = input("what you want to search:-") attacmentName = input("name of the attachment:-") download = ezgmail.search(gSearch) download[0].messages[0].downloadAttachment(attacmentName) if choice == '5': exit()
def mail_summary(): #print(parameters.get('Body')) main() ezgmail.init() unreadThreads = ezgmail.unread(maxResults=5) print(unreadThreads) return unreadThreads
def run(self): while (True): if (self.sendQueue.qsize() != 0): while (self.sendQueue.qsize() != 0): message = self.sendQueue.get() if (message['reportType'] == 'error'): ezgmail.send( self.emailAddress, 'ALERT ' + str(message['type']), 'warning triggered for ' + str(message['type']) + ' value = ' + str(message['value'])) elif (message['reportType'] == 'STATUS' or message['reportType'] == 'THRESHOLD_GET'): ezgmail.send(self.emailAddress, message['reportType'], message['value']) #check any inbound emails unreadThreads = ezgmail.unread() if (len(unreadThreads) != 0): for email in unreadThreads: msg = email.messages[0] if (int(self.AuthorisedReceiver) == 1): address = msg.sender[msg.sender.index('<') + 1:msg.sender.index('>')] if address != self.emailAddress: continue if msg.subject in recieveKeywords: self.receiveQueue.put(msg) ezgmail.markAsRead(unreadThreads) time.sleep(10)
async def steam_code(self, ctx): error_msg = "Belum sampe atau error, coba lgi ntar" for tries in range(3): try: unreadThreads = ezgmail.unread() msg = unreadThreads[0].messages[0].body msg = msg.split("This")[0].split(":")[-1].split()[0] if len(msg) == 5: msg = f"Kodenya: {msg}" else: msg = error_msg break except IndexError: if tries == 2: break message = await ctx.send(f"Ga ada email baru, nunggu bentar.. ({tries})") await asyncio.sleep(30) await message.delete() msg = error_msg await ctx.send(msg)
def test_basic(): assert ezgmail.EMAIL_ADDRESS == TEST_EMAIL_ADDRESS attachmentFilename = os.path.join( os.path.dirname(os.path.realpath(__file__)), 'attachment.txt') # This test doesn't check the results, it just makes sure these functions don't raise any exceptions: ezgmail.send(TEST_EMAIL_ADDRESS, TEST_SUBJECT, 'This is the body of the email.', [attachmentFilename]) unreadThreads = ezgmail.unread() unreadThreads[ 0] # NOTE: Make sure the test email account always has at least one unread message. ezgmail.summary(unreadThreads, printInfo=False) recentThreads = ezgmail.recent() msg = recentThreads[0].messages[0] msg.sender msg.recipient msg.subject msg.body msg.timestamp ezgmail.search('mancala')
import ezgmail from pdf2image import convert_from_path from pdf2image.exceptions import ( PDFInfoNotInstalledError, PDFPageCountError, PDFSyntaxError, ) import random from fpdf import FPDF ezgmail.init() Threads = ezgmail.unread() lookAt = len(Threads) count = 0 leonard_responses = [ "Spent more money again huh :/", "Leonard the bot says meow. You spend too much. Meow.", "MEOW MEOW MEOW MEOW MEOW MEOW MEOW ", "If Leonard could talk he'd say he's disappointed in you >:(", "silence", "money doesn't grow on trees!!", "do you have a job? then why you spend money!!! >:(", ] leonardSays = random.choice(leonard_responses)
def access_new_messages(self): self.messages = ezgmail.unread() return self.messages
# adding cc and bcc to messages ezgmail.send('*****@*****.**', 'Subject line', 'Body of the email', cc='*****@*****.**', bcc='[email protected],[email protected]') # If you need to remember which Gmail address the token.json file # is configured for, you can examine ezgmail.EMAIL_ADDRESS. ezgmail.init() ezgmail.EMAIL_ADDRESS # reading mail from gmail account unreadThreads = ezgmail.unread() # List of GmailThread objects. ezgmail.summary(unreadThreads) len(unreadThreads) str(unreadThreads[0]) len(unreadThreads[0].messages) str(unreadThreads[0].messages[0]) unreadThreads[0].messages[0].subject unreadThreads[0].messages[0].body unreadThreads[0].messages[0].timestamp unreadThreads[0].messages[0].sender unreadThreads[0].messages[0].recipient
def check_new_email(self): unread_threads = ezgmail.unread() if len(unread_threads) == 0: return None else: return unread_threads
# https://pypi.org/project/EZGmail/ # Using this requires some initial setup from: # https://developers.google.com/gmail/api/quickstart/python # to first grab the credentials file, then to get token.pickle from Google. import ezgmail from googleapiclient.errors import HttpError from playsound import playsound from time import sleep print("Watching for messages from EVGA.. ") count = 0 while True: try: unread_threads = ezgmail.unread() except HttpError: print("HTTP Error occurred. Rate limit probably exceeded. " "Waiting for some time.") sleep(1800) continue count += 1 if count % 2 == 0: print('beep boop..') else: print('boop beep!') if count % 10 == 0: print("Watching for messages from EVGA.. ")
# 인증된 이메일 주소 출력 print(f"내 이메일 주소: {ezgmail.EMAIL_ADDRESS}") # 메일 보내기 ezgmail.send( recipient="*****@*****.**", # 받는이 subject="Subject line", # 주제문 body="Body of the email", # 본문 attachments=["attachment.txt"], # 첨부 파일들 cc=None, # 참조 bcc=None, # 비밀참조 ) # 읽지 않은 메일 확인하기 unread_threads = ezgmail.unread() # GmailThread 객체 리스트 반환 ezgmail.summary(unread_threads) # 메일 속성 접근하기 print(f"안 읽은 메일 갯수: {len(unread_threads)}") unread = unread_threads[0] print(f"GmailThread 문자열 값: {unread}") print(f"안 읽은 첫 번째 메일의 메시지 갯수: {len(unread.messages)}") print(f" 메시지 주제문: {unread.messages[0].subject}") print(f" 메시지 본문: {unread.messages[0].body}") print(f" 메시지 시간: {unread.messages[0].timestamp}") print(f" 메시지 보낸이: {unread.messages[0].sender}") print(f" 메시지 받는이: {unread.messages[0].recipient}") # 최근 받은 메일 확인 (기본 25) recent_threads = ezgmail.recent(maxResults=100)
def __init__(self): unreadThreads = ezgmail.unread() # Collects unread email into lsit print("You have {} new emails".format(len(unreadThreads))) ezgmail.summary( unreadThreads ) # Command that provides name, subject line, and body of unread emails
### Carrega emojis OK = emoji.emojize(':heavy_check_mark:', use_aliases=True) NOK = emoji.emojize(':cross_mark:', use_aliases=True) ### Ids do Telegram botID = '784006906:AAF1qZj6fA9HdfdTijq04rmJ8nb5O43bmUg' channelID = '@datasciencetork' ### variaveis indir = '/home/ubuntu/scripts/load-dados-bmf/' bot = telepot.Bot(botID) print('Listening e-mail...') while (1): threads = ezgmail.unread() ### verifica e-mails marcados como não lidos for thread in threads: summary = ezgmail.summary(thread) sumary = ezgmail.summary(thread, printInfo=False) if '*****@*****.**' in sumary[0][0][0]: ### verifica se e-mail recebido é da B3 datetime = str(sumary[0][2]) bot.sendMessage(channelID,'Novo e-mail recebido da B3 às {} '.format(datetime) + OK) attachment = thread.messages[0].attachments[0] ### pega o nome do anexo thread.messages[0].downloadAttachment(attachment, indir) call('python '+indir+'parseResult.py',shell=True) call('python '+indir+'new_writeExcel.py',shell=True) call('python '+indir+'sendEmail.py',shell=True) exit(0) sleep(60)
import ezgmail #https://developers.google.com/gmail/api/quickstart/python unread = ezgmail.unread() summaries = ezgmail.summary(unread) print(unread[0].messages[0].body) #print(summaries)
def le_email(): unreadThreads = ezgmail.unread( maxResults=30) # List of GmailThread objects. ezgmail.summary(unreadThreads)