Embedding images

G

Guest

Please forgive me for the wordy description that follows:

I have written a sub in which I am translating different html documents
(mostly created via Word) to the HTMLBody of an email. The formatting comes
across great, but I can't quite figure out how to embed pictures.

I have a current work around that uses the URL's of images posted on the
internet (essentially, you place your images in Word where you want them,
then put those same images on the internet and are prompted for their URL as
the document is rewritten in the body). My code (less than elegant, but I'm
fairly new at this) is as follows:



Set FSO = CreateObject("Scripting.FileSystemObject")
Set bdy = FSO.OpenTextFile(strFileName)
strText = bdy.readall

intSearch = 1
intPicNum = 0
strText = Right(strText, Len(strText) - InStr(1, strText, "<body") + 1)
Do While intSearch < Len(strText)
If InStr(intSearch, strText, "img") = 0 Then
intSearch = Len(strText)
Else:
intSearch = InStr(intSearch, strText, "img")
intPicNum = intPicNum + 1
strText = Left(strText, InStr(intSearch, strText, "src=") + 4) &
InputBox ("Images sent through this utility MUST be posted on the
internet." & Chr(13) & "Please enter the FULL web address for this image." &
Chr(13) & "(e.g. http://www.myimage.com/image.jpg)" & Chr(13) & Chr(13) &
"Image No. " & intPicNum, "Picture Location") & Right(strText, Len(strText) -
InStr(intSearch, strText, strFormat) - Len(strFormat) + 1)
intSearch = intSearch + 8
End If
Loop
Set objOutlook = CreateObject("Outlook.Application")
Set objMail = CreateItem(olMailItem)

With objMail
.To = strTo
.Subject = strSubject
.HTMLBody = strBody
.Send
.Display
End With

I'm assuming that there is a much more elegant way to do this, and hopefully
one in which I can do so without having to post the images on the internet.
Any suggestions?

Thanks in advance
 
T

Tim Ferguson

The formatting comes
across great, but I can't quite figure out how to embed pictures.

Try googling on "MHTML".

Good email clients will recognise hrefs to external images as a security
hazard -- google on "web beacons".

Hope that helps



Tim F
 

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

Top