Convert HTML Message with Image

Use this forum if you have problems with a hMailServer script, such as hMailServer WebAdmin or code in an event handler.
Post Reply
mikedibella
Senior user
Senior user
Posts: 843
Joined: 2016-12-08 02:21

Convert HTML Message with Image

Post by mikedibella » 2024-08-28 19:12

Anyone have code written for a handler to insert a MIME attached image into the message HTML body as inline?

User avatar
RvdH
Senior user
Senior user
Posts: 3486
Joined: 2008-06-27 14:42
Location: The Netherlands

Re: Convert HTML Message with Image

Post by RvdH » 2024-08-28 19:18

mikedibella wrote:
2024-08-28 19:12
Anyone have code written for a handler to insert a MIME attached image into the message HTML body as inline?
good old CDOSYS can

Code: Select all

Set myMail=CreateObject("CDO.Message")
myMail.Subject= "Subject of Email"
myMail.From= "from@site.com"
myMail.To= "to@site.com"
myMail.CreateMHTMLBody "http://www.mysite.com/email.html"

strImagePath = Server.MapPath("\") & "\images\mypic1.jpg"
myMail.AddRelatedBodyPart strImagePath, "my_pic_1", 0

strImagePath = Server.MapPath("\") & "\images\mypic2.jpg"
myMail.AddRelatedBodyPart strImagePath, "my_pic_2", 0

myMail.Send
set myMail=nothing
https://stackoverflow.com/questions/109 ... sage-email
CIDR to RegEx: d-fault.nl/cidrtoregex
DNS Lookup: d-fault.nl/dnstools
DKIM Generator: d-fault.nl/dkimgenerator
DNSBL Lookup: d-fault.nl/dnsbllookup
GEOIP Lookup: d-fault.nl/geoiplookup

Post Reply