Python Forum
Add png to the body of the email, not the attachment
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Add png to the body of the email, not the attachment
#1
Hi,
Trying to find a way to add a png file located on the local PC to the body of the email. Went all over the Internet, but there is no solution to the problem. Everywhere offer simply attach the file to the letter. Found another option with the addition of the file in the body of the email, but the file is only added in case the location of the file on the web server. Can anyone tell if it is possible to use a Python to add a file located on the local PC to the body of the email? Or is there no point in wasting time?
Reply
#2
Hello! The email is a pure text. So you have to convert the image to text. Usually, base64 is the format most of the people are using.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#3
(Dec-13-2018, 10:27 AM)wavic Wrote: Hello! The email is a pure text. So you have to convert the image to text. Usually, base64 is the format most of the people are using.

I do not understand. And after this conversion, the recipient will display this picture as a picture? And what kind of module is used in this transformation?
Reply
#4
I want to clarify: I create a script that creates and sends an email. In the body of the email there should be a picture that can be viewed by the recipient.
Reply
#5
This is clear from your first post.

I didn't know how it works but I did some quick research. It's simple enough.
You add an HTML image tag to the message which contains the base64 data.

It is something like this: <img src="data:image/jpg;base64,base64 encoded data here" />

You can read about how to embed an image here for example. Look at "Inline Embedding (Base64 Encoding)" section.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#6
(Dec-13-2018, 11:21 PM)wavic Wrote: This is clear from your first post.

I didn't know how it works but I did some quick research. It's simple enough.
You add an HTML image tag to the message which contains the base64 data.

It is something like this: <img src="data:image/jpg;base64,base64 encoded data here" />

You can read about how to embed an image here for example. Look at "Inline Embedding (Base64 Encoding)" section.
THX. I will try your solution. Will write later...
PS
I dont see where i can put local path for file?
Reply
#7
You don't have to provide a source file to src attribute. Look at the example. You tell it that this is data and then the MIME type - image/png for instance.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#8
(Dec-14-2018, 10:25 AM)wavic Wrote: You don't have to provide a source file to src attribute. Look at the example. You tell it that this is data and then the MIME type - image/png for instance.

The recipient of this email will see a picture in the body of the email or will must to decode base64?
Reply
#9
The email client should handle it.

However,... did you look at the link at the bottom of my second post here? If you click on it and go to the section "Inline Embedding (Base64) Encoding)" there are pros and cons of each method for embedded images. Look at them. Perhaps you can use a different method according to the user client. Is it a web service or some email client... I use web email service for example.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Unable to download TLS Report attachment blason16 6 533 Feb-26-2024, 07:36 AM
Last Post: Pedroski55
  Extract PDF Attachment from Gmail jstaffon 0 575 Sep-10-2023, 01:55 PM
Last Post: jstaffon
  I get attachment paperclip on email without any attachments monika_v 5 1,963 Mar-19-2022, 10:20 PM
Last Post: cosmarchy
  Trying to determine attachment file type before saving off.. cubangt 1 2,141 Feb-23-2022, 07:45 PM
Last Post: cubangt
  Help Needed | Read Outlook email Recursively & download attachment Vinci141 1 4,075 Jan-07-2022, 07:38 PM
Last Post: cubangt
  Clicking Every Page and Attachment on Website shoulddt 1 1,731 Jul-09-2021, 01:08 PM
Last Post: snippsat
  ATT00001 instead of PDF attachment to an email dominiklucas 0 3,759 Jul-25-2020, 04:05 PM
Last Post: dominiklucas
  Sending an email with attachment without using SMTP? PythonNPC 5 3,167 May-05-2020, 07:58 AM
Last Post: PythonNPC
  How to Save Full Email Body to CLOB in Oracle w/Carriage Returns? bmccollum 1 2,278 Mar-12-2020, 10:25 PM
Last Post: Larz60+
  download base64 email attachment cferguson 3 4,720 Feb-25-2020, 06:50 PM
Last Post: cferguson

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020