More on Embedding Images
Question: Linking/Embedding Images in HTML Emails. This topic is really awesome and this is exactly what my requirement is. I have to embed the image because the requirement is that the graphics should be available even if the user sees the email offline(after downloading the html file on his pc.) But this topic does not even give a hint about as how such a functionality can be achieved. Could you please provide some more information about this?
anonymous
Answer: To attach files to an email or embed images into an email requires that you use MIME encoding.
- multipart/mixed allows you to specify that the email contains more than one section in different formats eg. text and attached file.
- multipart/alternate allows you to specify alternative sections that will be used depending on the functionality of the recipient's email program eg text and html
- multipart/related allows you to specify sections that will only be used if a related section is used eg to embed images into the html version while leaving the text version alone.
To get all of this to work the program creating the email has to insert the MIME encoding statements in the right places. Any sections not in plain text also have to be encoded appropriately.
Instructions on how to create html emails with embedded images using Outlook Express or Netscape/Mozilla Mail can be found at the bottom of the page you referred to. I have also written a PHP form2mail script that can handle all of the above to generate whatever you want in an email based on input from a form.


