Sending Hyperlinks in Body of an email

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am using VBA to sent emails to a recordset. However in the body of the
email I want to incluede a hyperlink to a web address as well as a hyperlink
to a file on a server. Any help in how to code these links. I want the
receiver of the email to be able to open the email and then click on these
links and be directed accordingly.

Thanks
 
If you're formating the email using HTML, its just a matter of formating
the link using HTML as in <a href="www.gateworld.net>Gateworld</a>. That
should do it.
 
David,

Thanks for your initial reply. I not sure if I'm formatting the email
specifically for HTML. Below you can see the code I'm workding with. There
are three areas in the code that reference "lnkpath". I not sure if I
Dimensioned, set or referecect it correctly. You assistance would be
appreciated.

Private Sub Command1_Click()
On Error GoTo Err_Command1_Click
Dim db As Database
Dim recToEmail As Recordset
Dim objOutlook As Object
Dim objEmail As Object
Dim strBody As String
Dim hypAddress As String
Dim lnkPath As String


hypAddress = "http://www.google.com"
lnkPath = "//pwn421b2280/testdatabase"

DoCmd.Hourglass True

Set db = CurrentDb()
Set recToEmail = db.OpenRecordset("qryClosedCalls")
Set objOutlook = CreateObject("Outlook.Application")

strBody = "Test, Test, Test" & vbCrLf & hypAddress & vbCrLf & lnkPath


While Not recToEmail.EOF
If Not IsNull(recToEmail("Contact_Email")) Then
Set objEmail = objOutlook.CreateItem(olMailItem)
With objEmail
.To = recToEmail("Contact_Email")
.Subject = "Test Email"
.Body = recToEmail("CONTACTFullName") & vbCrLf & strBody
.Save
End With
End If

recToEmail.MoveNext
Wend

recToEmail.Close
Set recToEmail = Nothing
Set objOutlook = Nothing
Set myMessage = Nothing


DoCmd.Hourglass False

Exit_Command1_Click:
Exit Sub

Err_Command1_Click:
MsgBox Err.Description
Resume Exit_Command1_Click
End Sub

Mike
 
Try adding the following to the with.
.BodyFormat = olFormatHTML
.HTMLBody = [body text here in quotes complete with the HTML tags]
 
David,

Thanks for your help. The information you provided did help resolve my issue

Thanks again

Mike

David C. Holley said:
Try adding the following to the with.
.BodyFormat = olFormatHTML
.HTMLBody = [body text here in quotes complete with the HTML tags]


David,

Thanks for your initial reply. I not sure if I'm formatting the email
specifically for HTML. Below you can see the code I'm workding with. There
are three areas in the code that reference "lnkpath". I not sure if I
Dimensioned, set or referecect it correctly. You assistance would be
appreciated.

Private Sub Command1_Click()
On Error GoTo Err_Command1_Click
Dim db As Database
Dim recToEmail As Recordset
Dim objOutlook As Object
Dim objEmail As Object
Dim strBody As String
Dim hypAddress As String
Dim lnkPath As String


hypAddress = "http://www.google.com"
lnkPath = "//pwn421b2280/testdatabase"

DoCmd.Hourglass True

Set db = CurrentDb()
Set recToEmail = db.OpenRecordset("qryClosedCalls")
Set objOutlook = CreateObject("Outlook.Application")

strBody = "Test, Test, Test" & vbCrLf & hypAddress & vbCrLf & lnkPath


While Not recToEmail.EOF
If Not IsNull(recToEmail("Contact_Email")) Then
Set objEmail = objOutlook.CreateItem(olMailItem)
With objEmail
.To = recToEmail("Contact_Email")
.Subject = "Test Email"
.Body = recToEmail("CONTACTFullName") & vbCrLf & strBody
.Save
End With
End If

recToEmail.MoveNext
Wend

recToEmail.Close
Set recToEmail = Nothing
Set objOutlook = Nothing
Set myMessage = Nothing


DoCmd.Hourglass False

Exit_Command1_Click:
Exit Sub

Err_Command1_Click:
MsgBox Err.Description
Resume Exit_Command1_Click
End Sub

Mike


:
 

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

Back
Top