Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Send Email With Picture Embedded in Body of Email

by pryrt (Abbot)
on Sep 09, 2020 at 19:43 UTC ( [id://11121524]=note: print w/replies, xml ) Need Help??


in reply to Send Email With Picture Embedded in Body of Email (SOLVED)

Can anyone provide the additional code required to embed the JPG picture in the body of the email using Net::SMTPS? Thanks in advance for your help.

# Email body. $smtp->datasend("--$boundary\n"); $smtp->datasend("Content-type: text/plain\n");

You have a conflict between your code and your problem description. Your problem description says that you want to embed an image, but your code shows that you are using plaintext. You cannot "embed an image" in plaintext. When Outlook sends an email with embedded images, it is either in rich text format, or in HTML. (I can see this when I compose a message in my Office 2016 Outlook client: the "Format Text" menu will show either HTML Text, Plain Text, or Rich Text. If you have an embedded image and select Plain Text, the embedded image goes away, because images are not plain text.)

So instead of doing a Content-type: text/plain, use the right header for rich text or html, and format the data in that section of the email as either rich text or html. And sorry, I don't know how to set an HTML img src to point to an attachment in your email: if you send yourself a rich text email and an HTML text email, both with embedded images, from Outlook to someplace that can read the actual source of the email, then you can see how exactly the rich text or HTML are structured to link to the image.

Replies are listed 'Best First'.
Re^2:Send Email With Picture Embedded in Body of Email
by roho (Bishop) on Sep 09, 2020 at 20:49 UTC
    Sorry for the confusion. The plain text section is there as a placeholder. I need to know how to change the pain text section to embed a picture instead of displaying text. I have been unable to find a working example of the code required to do this, and that is what I am asking the Monastery for.

    "It's not how hard you work, it's how much you get done."

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11121524]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2024-03-29 01:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found