Commit e1bc3832 authored by vipul.v's avatar vipul.v

first

parent 9ae5b679
i
9venv/Lib/site-packages/uvicorn/protocols/http/h11_impl.py,8\7\87c1108482c4497c577e9a478a6a458efd708820
K
script/config/app_config.py,e\7\e7a8f69b82d0d0839cd67ff968caeb054957923f
]
-.idea/sonarlint/securityhotspotstore/index.pb,8\8\88a9255124c95bdc913197c120a8d560edc59c8e
E
conf/application.conf,6\4\644f59db746795ef1538ef95c4cbc0eab6663e28
^
..idea/inspectionProfiles/profiles_settings.xml,1\e\1e9075f5bf079c01ef2c910709e91a497d262080
\
,.idea/inspectionProfiles/Project_Default.xml,4\9\496a238a6afa168dbaf6efd37bb459331589579c
\ No newline at end of file
i
9venv/Lib/site-packages/uvicorn/protocols/http/h11_impl.py,8\7\87c1108482c4497c577e9a478a6a458efd708820
K
script/config/app_config.py,e\7\e7a8f69b82d0d0839cd67ff968caeb054957923f
]
-.idea/sonarlint/securityhotspotstore/index.pb,8\8\88a9255124c95bdc913197c120a8d560edc59c8e
E
conf/application.conf,6\4\644f59db746795ef1538ef95c4cbc0eab6663e28
^
..idea/inspectionProfiles/profiles_settings.xml,1\e\1e9075f5bf079c01ef2c910709e91a497d262080
\
,.idea/inspectionProfiles/Project_Default.xml,4\9\496a238a6afa168dbaf6efd37bb459331589579c
\ No newline at end of file
import smtplib import smtplib
import ssl
from email.message import EmailMessage
from email.mime.multipart import MIMEMultipart from email.mime.multipart import MIMEMultipart
...@@ -6,19 +8,26 @@ class SendEmail: ...@@ -6,19 +8,26 @@ class SendEmail:
@staticmethod @staticmethod
def send_file(sender_email, receiver, sender_password): def send_file(sender_email, receiver, sender_password):
try: try:
with smtplib.SMTP('smtp.gmail.com', 587) as smtp: files = ['Weather Report_daily.xlsx','Weather Report_weekly.xlsx','Weather Report_monthly.xlsx']
msg = MIMEMultipart() msg = EmailMessage()
msg['From'] = sender_email msg['From'] = sender_email
msg['To'] = receiver msg['To'] = receiver
msg['Subject'] = "weather report" msg['Subject'] = "weather report"
smtp.starttls() context = ssl.create_default_context()
with open("Weather Report_daily.xlsx", "rb") as file: for file_read in files:
with open(file_read, "rb") as file:
print("sjsjhj")
file_data = file.read() file_data = file.read()
file_name = file.name file_name = file.name
msg.add_attachment(file_data, maintype="weather", subtype="xlsx", filename=file_name) print(file_name)
# part['Content-Disposition'] = 'attachment; filename="%s"' % basename(f)
msg.add_attachment(file_data, maintype="application", subtype="xlsx", filename=file_name)
with smtplib.SMTP_SSL('smtp.gmail.com', 465, context=context) as smtp:
print("skfknk")
smtp.login(sender_email, sender_password) smtp.login(sender_email, sender_password)
smtp.send_message(msg) smtp.sendmail(sender_email, receiver, msg.as_string())
# smtp.starttls()
except ValueError: except ValueError:
raise ValueError raise ValueError
except Exception as e: except Exception as e:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment