Sending a clickable email

R

RoyT

Hi

I am trying to send an email from within ACCESS using automation to send the
email via Outlook.

I have set up the code and I can send the email but I want the image in my
email to be 'clickable' so that when the user clicks on the image they get
taken to a website. It all works OK but the user cannot see the image. I
obviously need to embed the image in the email somehow. Can anyone help
please???

The code I am using is:

Set objOutlook = New Outlook.Application
Set db = CurrentDb()
Set qryDef = db.QueryDefs("qryMail")
qryDef.Parameters(0) = Me.cmbPostCode.Value
Set rstMail = qryDef.OpenRecordset
Do Until rstMail.EOF

' This creates the e-mail
Set objMail = objOutlook.CreateItem(olMailItem)

' This addresses it
objMail.To = rstMail("Email")

'This gives it a subject
objMail.Subject = strSubject

'This gives it the body
objMail.HTMLBody = "<html><head><meta http-equiv='Content-Type'
content='text/html; charset=windows-1252'>" _
& "<title>New Page 1</title></head><body><p><a
href='http://www.rothco.co.uk'><img border='0'
src='file:///C:/Clients/Roy/email%20front12.gif' width='960'
height='720'></a></p>" _
& "</body></html>"

objmail.Send
'objMail.Display

'And on to the next one...
rstMail.MoveNext
Loop

Set objOutlook = Nothing
Set db = Nothing
Set qryDef = Nothing
Set rstMail = Nothing
Set objMail = Nothing
 
S

Sue Mosher [MVP-Outlook]

Adding an image to the body of a message in Outlook takes quite a bit more
effort. See http://www.outlookcode.com/d/code/htmlimg.htm for a code sample.
If that doesn't work for you, give your Outlook version. Also, if the same
image is supposed to appear in each message, an easier approach is to build
at least that part of the message manually, save it as an .oft file, and
invoke it with CreateItemFromTemplate.
 
R

RoyT

Hi Sue

Thanks for your help.

I have managed to work out a way of doing it which is fairly
straightforwards. Just for information the code I have added/amended is:

Set objAttachments = objMail.Attachments
objAttachments.Add "C:/Clients/Roy/email front12.gif' ", _
olByValue, 0, "Page.gif"

'This gives it the body
objMail.HTMLBody = "<html><head><meta http-equiv='Content-Type'
content='text/html; charset=windows-1252'>" _
& "<title>New Page 1</title></head><body><p><a
href='http://www.rothco.co.uk/'><img border='0' src='cid:email front12.gif'
width='960' height='720'></a></p>" _
& "</body></html>"

Basically, add the gif as an attachment and point the body to it via a cid:

Then add an anchor href with the web site around the image and it all works
fine. The third parameter in the add attachments (0) sets the attachment to
be invisible.

Thanks again

Roy
 

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