Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6860185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:22:36+00:00 2026-05-27T02:22:36+00:00

I have develop a function in PYTHON that sends emails with one .doc attachment

  • 0

I have develop a function in PYTHON that sends emails with one .doc attachment and one image attachment (.jpg)

The message of the email is HTML.

I want to know how to display the Attached Image on the HTML message….is there any instruction that can help me with this???

Thanks a lot….
Here is the function I developed

def enviarCorreo(fromaddr, toaddr, text, file, imagen_1, imagen_2):
   msg = MIMEMultipart('mixed')
   msg['From'] = fromaddr
   msg['To'] = toaddr
   msg['Subject'] = 'asunto'
   msg.attach(MIMEText(text,'HTML'))

   #IMAGE ATTACHMENT *******************************************
   adjuntoImagen_1 = MIMEBase('application', "octet-stream")
   adjuntoImagen_1.set_payload(open(imagen_1, "rb").read())
   encode_base64(adjuntoImagen_1)
   anexoImagen_1 = os.path.basename(imagen_1)
   adjuntoImagen_1.add_header('Content-Disposition', 'attachment; filename= "%s"' % anexoImagen_1)
   msg.attach(adjuntoImagen_1)

   #FILE ATACHMENT **********************************************
   adjunto = MIMEBase('application', "octet-stream")
   adjunto.set_payload(open(file, "rb").read())
   encode_base64(adjunto)
   anexo = os.path.basename(file)
   adjunto.add_header('Content-Disposition', 'attachment; filename= "%s"' % anexo)
   msg.attach(adjunto)

   #SEND ********************************************************
   server = smtplib.SMTP('localhost')
   server.set_debuglevel(1)
   server.sendmail(fromaddr, toaddr, msg.as_string())
   server.quit()
   return
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T02:22:37+00:00Added an answer on May 27, 2026 at 2:22 am

    In your html, use img tags with a src of:

    cid:<filename used in your Content-Disposition header>
    

    So, for instance:

    <p>
    <img src="cid:image1.jpeg"/>
    </p>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have used sendinput() function and windows keyboard hooks to develop a custom keyboard
Hi i have develop and deploy one multilingual (english uk and swedish) website at
I have to develop an application which parses a log file and sends specific
I have to develop an application using C#.net that has to be run once
I have to develop software for a USB scale that, when you press a
I have to develop a tool in C# that retrieves some data from an
I'm try develop an ActiveX Control in VB6. It have one UserControl and one
I have a GlassFish/j2ee application, and I develop on one box, and production is
int duplicate (int cards[5][4][13]) I have been trying to develop a function (the prototype
I am trying to develop a function that removes certain URL nodes from my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.