the main reason i went looking for a means to embed images, was to avoid that terrible (red x) where my images SHOULD have been in the email message… it just seems too unprofessional to have what appears to be a “broken” message (to my clients)…
having said that, im certainly open to other means of getting images into my messages… i just find it to be a much more pleasing experience (myself) when i open email from reputable sources, and find a nicely crafted message (from vendors like TigerDirect, or online services like WoW, etc.)…
hi group,
thanks for the wonderful code example. I was looking for this for quite a long time…but unfortunately whatever code I could come up with, did not work with all the mail clients.
I have tested the above given code example and it works flawlessly on the following email clients.
a)outlook b)pegasus mail c) lotus note d)gmail e)yahoo
I had a further requirement that I wanted to embed two images in one mail.(the example shows embedding only one)
as suggested by the orginal author, we need to create one more object of add relatedbodypart like this
Code:
Set objBP2 = objCDO.AddRelatedBodyPart(Server.MapPath(“/images/myimage2.gif”), “myimage2.gif”, CdoReferenceTypeName)
objBP2.Fields.Item(“urn:schemas:mailheader:Content-ID”) = “<myimage2.gif>”
objBP2.Fields.Update
however I tried a different method, instead of creating objBP1 and objBP2 I used the same but in between I wrote objBP.Fields.Update. Now its working for me.
my code:
Set objBP = objCDO.AddRelatedBodyPart(“c:\birthday\cake4.jpg”, “cake.jpg”, CdoReferenceTypeName)
objBP.Fields.Item(“urn:schemas:mailheader:Content-ID”) = “<cake.jpg>”
objBP.Fields.Update
Set objBP = objCDO.AddRelatedBodyPart(“c:\birthday\logo.jpg”, “logo.jpg”, CdoReferenceTypeName)
objBP.Fields.Item(“urn:schemas:mailheader:Content-ID”) = “<logo.jpg>”
objBP.Fields.Update
once again thanks for the code…it works like a charm ! ! !
Hi adhunna, it works exactly the same as my original post, read it carefully. There are a few errors in your code so it won’t work as you have it. The following code works fine for me.