Sending a clickable email

  • Thread starter Thread starter Um95VA
  • Start date Start date
Status
Not open for further replies.
U

Um95VA

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

Roy Thompson

Independent Developer

Specialist in Sage Accounting solutions (UK)
 
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.

Sue Mosher

"RoyT" wrote:


> 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

> > Roy Thompson
> Independent Developer
> Specialist in Sage Accounting solutions (UK)
 
Clickable Email

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
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
W Outlook 2021 Hanging on "Sending Emails" Using Outlook 3
Fozzie Bear Calendar Events created on iPhone have suddenly start sending invitations to attendees Using Outlook 2
D Prompt to prefix subject line whenever sending an email Outlook VBA and Custom Forms 3
P default font when sending email from browser Using Outlook 1
M Messages Intermittently Dont Arrive In Sent Items After Sending Successfully Using Outlook 4
O Outlook on Android: after sharing / sending a news article, draft remains open. Why? Using Outlook 1
P Sending email from outlook IMAP to GMAIL where embedded images are added as attachment Using Outlook 1
V Form data not sending for some users Outlook VBA and Custom Forms 2
L isn't there an OL add-on that flags addressee before sending Using Outlook 3
R Microsoft Outlook 2016 - Gmail not sending, asks for password for SMTP, tried different ports Using Outlook 23
A Flag Message for Follow Up after sending Outlook VBA and Custom Forms 1
D Sending email from Office 365 alias in Outlook Using Outlook 3
E Change sending account depending on Subjectline Outlook VBA and Custom Forms 0
L unblocking attachments before sending Office 365 Advanced Protection Using Outlook 0
B Outlook 2003 email sending & receiving suddenly stopped working Using Outlook 3
R Warn before sending message Outlook VBA and Custom Forms 4
HarvMan Hotmail - Sending email is undeliverable Using Outlook 4
A Sending contact vcards sends older version instead of updated version Using Outlook 4
M McAllister Outlook stops Sending/Receiving/Synching after disconnecting remote desktop session Using Outlook 2
D Adding Enterprise Exchange Email Account to Outlook Prevents Sending via Outlook.com Account Using Outlook.com accounts in Outlook 10
B When sending an email, I am showing 2 of my address's Using Outlook 1
M Auto expand Distribution List Before Sending Email Outlook VBA and Custom Forms 1
A Check for words in subject header before sending email Outlook VBA and Custom Forms 4
O Run macro automatically at sending an email Using Outlook 11
W Sending To Wrong Account Using Outlook 15
H Select Specific Account When Sending Email, Based on Current Folder Outlook VBA and Custom Forms 1
M Help sending email but removing signature via VBA Outlook VBA and Custom Forms 5
M MsgBox when not sending from specified account Outlook VBA and Custom Forms 2
A Script to fetch data from mails in restricted collection and sending them to excel Using Outlook 1
R Sending emails via Outlook XP, from Windows 10 File Explorer Using Outlook 1
L Creating drafts when I thought I was sending Using Outlook 1
C address book "when sending email" bug? Using Outlook 0
H Custom autoforwarding, sending mail through outlook office 365 Using Outlook 1
R Sending email copy (*.msg file) of sent email if subject line contains specific string. Outlook VBA and Custom Forms 1
C replace subject line generated by converting a word document to PDF and sending it to an email Using Outlook 8
A Sending Emails Through Outlook From Multiple Email Addresses Using Outlook 1
P Outlook 365 sending intermittently Using Outlook 0
C How to avoid sending mail to the wrong contact person Using Outlook 1
V iCloud Calendar invitations not sending Using Outlook 3
O Rules and Alerts for New Messages BEFORE sending Using Outlook 2
latitudeit Outlook for Android - Sending from an alias address Using Outlook 2
X Delay sending an email until the next working day (public holidays) Outlook VBA and Custom Forms 0
D Macro sending outlook template from Excel list Outlook VBA and Custom Forms 6
A How to get rid of "sending on behalf of" when sending from Outlook 2016 client Using Outlook 12
O Outlook 2013 Problems sending large mails Using Outlook 4
Diane Poremsky Automatically create a task when sending a message Using Outlook 0
P Categorise emails on sending - macro not working in Preview mode Using Outlook 1
Diane Poremsky Outlook is sending winmail.dat attachments Using Outlook 0
Diane Poremsky Select from a List of Subjects before Sending a Message Using Outlook 0
P Outlook 2010 sending safe senders email to junk box Using Outlook 8

Similar threads

Back
Top