Embedding images and dynamic content in an email, programmatically

C

Chris Nafziger

In my code to send email from VBScript, I use standard CDOSYS code similar to
the following:

With oMsg
Set .Configuration = oCon
.To = """Admin"" <[email protected]>"
.From = """Joe Admin"" <[email protected]>"
.Subject = "Hey You!"
.TextBody = "Service(s) have failed!"
.Send
End With

I understand the use of the .HTMLBody property, as well as the
..CreateMHTMLBody method. So I know I can create an ASP or HTML page, and
pass it to the .CreateMHTMLBody method, to get the images truly embedded, so
the email source contains the cid:blahblahblah references to the images,
which is key to getting the email to display properly in web-based mail
clients.

My question is... how do I achieve the same thing (embed the images) that
the .CreateMHTMLBody method does automatically, manually, so I can also
inject values passed from a form postback into the email?

It seems that I shouldn't use the .CreateMHTMLBody method. It seems that I
need to manually accomplish what it accomplishes automatically, so I have
more granular control. But I have found no thorough online resources that
explain exactly how. I have thoroughly looked at all of the SDK information
pertaining to CDOSYS, and I am still in dire need of an example for
VBScript...

It seems that the .AddRelatedBodyPart method is part of the answer, but when
I use it to embed the images and fill .HTMLBody, rather than using the
..CreateMHTMLBody method, I do not see cid:blahblahblah in the email source,
and the images do not display properly in web-based mail clients such as
Outlook Web Access.

I really need some help on this. It would also appear that I am not alone.
I find plenty of questions on this, but no answers. Can anyone help with a
working VBScript example that embeds images into an email in a fashion that
yields the cid:blahblahblah in the email source, for the image references,
that does not use the .CreateMHTMLBody method to do the work automatically?
 
A

Alex Deveza

The answer is to use .addRelatedBodyParts, the example that they provide is
missing something, the place where "..src=""xyz.gif"" is mentioned, you
should modify the HTML to say "...src=""cid:xyz.gif"", and reference
"xyz.gif" when you call addRelatedBodyParts. I was working on these for days,
and by just mere luck, I stumble onto it...hope this helps.

Alex
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top