I want to send an email with html code and an image
but in gmail it says that the image is attached, I don’t want that, I only want the image in the body of the email.
html_content=f"<img src="cid:banner" alt="" style="width:80%;">"
msg = MIMEMultipart('related')
html_part = MIMEText(html_content, 'html')
msg.attach(html_part)
with open(image_path, 'rb') as f:
image_data = f.read()
image_attachment = MIMEImage(image_data,'html', name='Logo')
image_attachment.add_header('Content-ID','<banner>') # Unique identifier for the image
msg.attach(image_attachment)
# Subject of E-mail
msg['Subject'] = f"Aire Frio Maracay ❄"
# Sender E-mail Id
sender = '[email protected]'
msg['From'] = sender
# Receiver E-mail Id
recipient = '[email protected]'
msg['To'] = recipient
# SMTP Server
server = smtplib.SMTP_SSL('smtp.zoho.com', 465)
# SMTP Server Login Credentials
server.login(sender, 'gYDY04USz6ru')
# Gives Send Mail Request to SMTP Server
server.sendmail(sender, recipient, msg.as_string())
# Quit or Logout from SMTP Server
server.quit()
i dont wanna this
i just want this
i was try search in youtube and ask gemini IA but i not found sololution
New contributor
Salem is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.