"email.MIMEBase" Code Answer's
You're definitely familiar with the best coding language Whatever that developers use to develop their projects and they get all their queries like "email.MIMEBase" answered properly. Developers are finding an appropriate answer about email.MIMEBase related to the Whatever coding language. By visiting this online portal developers get answers concerning Whatever codes question like email.MIMEBase. Enter your desired code related query in the search bar and get every piece of information about Whatever code related question on email.MIMEBase.
email.MIMEBase
import smtplib
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
from email.MIMEBase import MIMEBase
from email import encoders
fromaddr = "YOUR EMAIL"
toaddr = "EMAIL ADDRESS YOU SEND TO"
msg = MIMEMultipart()
msg['From'] = fromaddr
msg['To'] = toaddr
msg['Subject'] = "SUBJECT OF THE EMAIL"
body = "TEXT YOU WANT TO SEND"
msg.attach(MIMEText(body, 'plain'))
filename = "NAME OF THE FILE WITH ITS EXTENSION"
attachment = open("PATH OF THE FILE", "rb")
part = MIMEBase('application', 'octet-stream')
part.set_payload((attachment).read())
encoders.encode_base64(part)
part.add_header('Content-Disposition', "attachment; filename= %s" % filename)
msg.attach(part)
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server.login(fromaddr, "YOUR PASSWORD")
text = msg.as_string()
server.sendmail(fromaddr, toaddr, text)
server.quit()
Source: stackoverflow.com
email.MIMEBase
as.string()
|
+------------MIMEMultipart
| |---content-type
| +---header---+---content disposition
+----.attach()-----+----MIMEBase----|
| +---payload (to be encoded in Base64)
+----MIMEText
Source: stackoverflow.com
All those coders who are working on the Whatever based application and are stuck on email.MIMEBase can get a collection of related answers to their query. Programmers need to enter their query on email.MIMEBase related to Whatever code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about email.MIMEBase for the programmers working on Whatever code while coding their module. Coders are also allowed to rectify already present answers of email.MIMEBase while working on the Whatever language code. Developers can add up suggestions if they deem fit any other answer relating to "email.MIMEBase". Visit this developer's friendly online web community, CodeProZone, and get your queries like email.MIMEBase resolved professionally and stay updated to the latest Whatever updates.