Using HREF from field in Access in Outlook

Douglas Post

Registered User.
Local time
Today, 01:47
Joined
Feb 10, 2012
Messages
22
I have a field called "Listing Link". In that field there is a full URL path. I want to put this in the body of my email as a link. I have identified the field as:

Code:
ListingLink = Me!
[Listing Link]
I try to populate the body of the email with:

Code:
"<A HREF=ListingLink>Link to Listing</A>"
But what I get is the URL referencing "ListingLink" not the complete URL contained in
[Listing Link]. I have tried double quotes, brackets, etc. I am sure it is just a formatting issue.

Here is my full code:

Code:
Private Sub Send_Info_Click()
  
    Dim OutApp As Object
    Dim OutMail As Object
    Dim Strbody As String
    Dim SigString As String
    Dim Signature As String
    Dim SendEmail As String 'SendEmail is the hyperlink field containing the email address

    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)

    SendEmail = Left(Me!Email, InStr(1, Me!Email, "#") - 1) 'This removes the #mailto:XXX@XXXXX#
    Address = Me!Address
    City = Me!City
    State = Me!State
    Zip = Me!Zip
    MLS = Me!MLS
    ListingLink = Me!
[Listing Link]
    Strbody = "<font face=verdana size=2 color=#4F81BD>Dear Customer<br>" & _
              "Please visit this website to download the new version.<br>" & _
              "Let me know if you have problems.<br>" & _
              "<A HREF=ListingLink>Link to Listing</A></font>"

    SigString = "C:\Users\Douglas Post\AppData\Roaming\Microsoft\Signatures\Brokerage Activity.htm"

    If Dir(SigString) <> "" Then
        Signature = GetBoiler(SigString)
    Else
        Signature = ""
    End If

    On Error Resume Next
    With OutMail
        .To = SendEmail
        .From = "post@theLOcompany.com"
        '.CC = ""
        '.BCC = ""
        .Subject = Address & ", " & City & ", " & State & " " & Zip & " (MLS#" & MLS & ")"
        .HTMLBody = Strbody & "<br><br>" & Signature
        '.Attachments.Add ("C:\test.txt")
        .Display 'or use .Send if you want to send without preview
        '.ReadReceiptRequested = True or False
        .Importance = 2 'Importance Level  0=Low,1=Normal,2=High
        '.Save
    End With

    On Error GoTo 0
    Set OutMail = Nothing
    Set OutApp = Nothing
End Sub

Function GetBoiler(ByVal sFile As String) As String
    Dim fso As Object
    Dim ts As Object
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set ts = fso.GetFile(sFile).OpenAsTextStream(1, -2)
    GetBoiler = ts.readall
    ts.Close
End Function
 
Just figured it out. I needed to write the code as:

Code:
"<A HREF=" & ListingLink & ">Link to Listing</A></font>"
 

Users who are viewing this thread

Back
Top Bottom