Sending HTML mails with pictures

Discussions related to Visual Prolog
User avatar
Tonton Luc
VIP Member
Posts: 500
Joined: 16 Oct 2001 23:01

Unread post by Tonton Luc » 7 Feb 2007 11:27

Hi,
Sending mail with content-type = "text/html" works fine too.
But when the html page contains a picture, the recipient does not see it (because picture's src = \"file:///D:/MyPicture.JPG\").
I tested setContentType("multipart/alternative") without success.
Any suggestion ?

Code: Select all

clauses     onTestCorpsHtml(_Source, _MenuTag):-         string5x::list_to_string(["<html>",             "<head>",             "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1252\">",             "<meta name=\"GENERATOR\" content=\"Microsoft FrontPage 4.0\">",             "<meta name=\"ProgId\" content=\"FrontPage.Editor.Document\">",             "<title>Nouvelle page 1</title>",             "</head>",             "<body onContextMenu=\"return false\">",             "<form method=\"POST\" action=\"\" name=\"frm\">",             "<p><img border=\"0\" src=\"file:///D:/...xxx.../MyPicture.JPG\" width=\"668\" height=\"390\"></p>",             "</form>",             "</body>",             "</html>"],"",Message),                 M = sendMail_smtp::new("smtp.wanadoo.fr"),         M:setContentType("text/html"),         M:send(["lucg@jdklog.com"],[],"lucg@jdklog.com","Test 2",Message),         stdIO::writef("ok\n"),         !.

User avatar
Thomas Linder Puls
VIP Member
Posts: 1622
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls » 7 Feb 2007 14:10

There are two ways to deal with images in HTML.
  • Either the HTML can link to an image on the Internet.
  • Or the Image can be attached to the mail and the link should then go to the attachment.
The first method is often used when sending out news letters etc, because the news letter (and hence the images) is often on the Internet anyway. It is a solid method that almost always works.

The second method makes the mail self contained, on the other hand some mail clients does not handle it properly.

The second method also has the problem that I don't know how it is done ;-). But I can tell you that it has to do with MIME (Multipurpose Internet Mail Extensions) and Multipart Messages.

If you learn it, please teach us how to do it.
Regards Thomas Linder Puls
PDC

User avatar
Tonton Luc
VIP Member
Posts: 500
Joined: 16 Oct 2001 23:01

Unread post by Tonton Luc » 7 Feb 2007 14:22

If you learn it, please teach us how to do it.
Ok, no problm.
For the moment, I'll use the first method. Thanks.

drspro2
VIP Member
Posts: 78
Joined: 28 Apr 2006 12:03

Unread post by drspro2 » 25 Jan 2014 11:53

I think this link might be usefull,



http://htmlemailboilerplate.com/

User avatar
Jan de Lint
VIP Member
Posts: 107
Joined: 6 Mar 2000 0:01

Unread post by Jan de Lint » 4 Feb 2014 9:00

Indeed, thanks!
]an

Post Reply