Results 1 to 5 of 5

Thread: Creating a Hyperlink Alias in VB?

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2003
    Posts
    3

    Question Creating a Hyperlink Alias in VB?

    I am trying to create an Outlook email message with hyperlinks from Access using a VB module. Everything works fine, but now I want to change the way the hyperlinks are displayed. Instead of giving the entire hyperlink address I want to give an alias. Example: Instead of reading "Click here to go to Hotmail - http://www.hotmail.com" It should read "Click here to go to Hotmail". Hotmail should be the hyperlink with the address hidden.

    How do I create the alias?

    Here is what I have so far:

    Function SnapMailMessage()

    Dim ol As New Outlook.Application
    Dim ns As Outlook.NameSpace
    Dim newMail As Outlook.MailItem

    'Return a reference to the MAPI layer.
    Set ns = ol.GetNamespace("MAPI")

    'Create a new mail message item.
    Set newMail = ol.CreateItem(olMailItem)
    With newMail
    'Add the subject of the mail message.
    .Subject = "The Subject"

    'Attach a file
    With .Attachments.Add _
    ("C:\WINNT\WINNT\file.xls")
    .DisplayName = "Your File Details"
    End With

    'Create some body text.
    '.Body = "Click here to go to Hotmail - http://www.hotmail.com/" & vbCrLf

    'Diplay the email
    .Display
    End With

    'Release memory.
    Set ol = Nothing
    Set ns = Nothing
    Set newMail = Nothing
    End Function

  2. #2

    Thread Starter
    New Member
    Join Date
    Dec 2003
    Posts
    3
    I got my answer. Just in case anyone is interested here is how I did it.

    .HTMLBody = "<HTML><BODY><A HREF='http://www.hotmail.com'> Click here</A></BODY></HTML>"

  3. #3
    Fanatic Member Matt_T_hat's Avatar
    Join Date
    Dec 2001
    Location
    '76 Male Body Evil-Errors: 666
    Posts
    774
    basic HTML then.
    ?
    'What's this bit for anyway?
    For Jono

  4. #4

    Thread Starter
    New Member
    Join Date
    Dec 2003
    Posts
    3
    Yeah.. the key was the .HTMLBody. The rest is pure HTML.

  5. #5
    New Member
    Join Date
    Feb 2013
    Posts
    1

    Post Re: Creating a Hyperlink Alias in VB?

    Thanks EPA for your solution to use HTML for creating an alias name for a hyperlink. That does indeed work but I have too much in my Outlook email to use all HTML so do you or anyone else know how to either embed into VB coding or joining more than one HTL statements.

    I have attached the code I have so far which does work but with no alias names. Neither does the attachment part work which I have used from EPA code which I thought was a good idea. When I put in a precise file name it highlights the Attachments words saying "Invalid or unqualified reference - "

    My code is the following...can anyone help please?

    ****** Start of coding ******


    Dim Email, ref, origin, destination, Notes As String
    Dim objOutlook As Outlook.Application
    Dim objEmail As Outlook.MailItem

    '**gathers information from your form. this sets the string variable to your fields
    Email = Me!Email
    InvNum = Me!InvNum
    dateofhire = Me!BookingDate
    Dear = Me!Dear
    GrossCost = Me!GrossCost
    PayMethod = Forms![FRM - Invoice]![subFRM - Income]!PayMethod
    PaidAmount = Forms![FRM - Invoice]![subFRM - Income].Form.IncomeAmount
    OutTime = Format$([OutTime], "h:nnam/pm", 0, 0)
    ReturnTime = Format$([ReturnTime], "h:nnam/pm", 0, 0)

    Body1 = Dear & DDline & "Many thanks for confirming your booking with us by paying the deposit of " & Format$(PaidAmount, "£#,##0.00", 0, 0) & " by card over the phone." & DDline & "Please find attached your booking confirmation which you should print off and have with you on the day of hire."
    Body2 = "If you cannot view the attached booking confirmation please visit Adobe UK (" & "http://www.adobe.com/uk" & ") to download the free Adobe reader." & DDline & "I have your card receipt here, if you would like it for your records please remind me for it on the day of hire."
    Body3 = "You can follow us on Twitter (" & "http://www.twitter.com/ellerbecknb" & ") or become a fan on Facebook (" & "http://www.facebook.com/boatstohire" & ") (Please select the 'Like' button). Your comments and photos on board would be much appreciated either from your mobile devices on board, or your computer when you get home." & DDline & "Please be aware that the balance of " & Format$(([GrossCost] - [PaidAmount]), "£#,##0.00", 0, 0) & " plus a returnable £50.00 security deposit will be payable when you arrive on the day."
    Body4 = "Thanks again for your booking and we look forward to seeing you and your party on " & Format$(dateofhire, "dddd dd mmmm yyyy", 0, 0) & " at " & Format$([OutTime], "h:nnam/pm", 0, 0) & " until " & Format$([ReturnTime], "h:nnam/pm", 0, 0) & "."
    Body5 = "Regards" & DDline & "Lucien Burkhardt" & Dline & "Partner" & Dline & "Ellerbeck Narrowboats" & Dline & "01257 480 825" & Dline & "http://www.boatstohire.co.uk" & DDline & "DISCLAIMER: This e-mail and any attachments may be confidential. It is intended for the addressee only and may contain information that is privileged. Any views or opinions expressed are solely those of the author and do not necessarily represent those of Ellerbeck Narrowboats. If you are not the intended recipient, you must not copy, distribute or take any action upon its contents. If this e-mail has been sent to you in error, please notify us immediately." & DDline & "Although Ellerbeck Narrowboats operates anti-virus programs, it does not accept responsibility for any damage whatsoever that is caused by viruses being passed. Replies to this email may be monitored and/or recorded by Ellerbeck Narrowboats for operational or business reasons."

    '***creates an instance of Outlook
    Set objOutlook = CreateObject("Outlook.application")
    Set objEmail = objOutlook.CreateItem(olMailItem)

    '***attach a file
    With .Attachments.Add("C:\Data\Ellerbeck Narrowboats\Confirmations - Emailed\2013\DBB0313003.pdf")
    .DisplayName = "Your booking confirmation"
    End With

    '***creates and sends ema il
    With objEmail
    .To = Email
    .Subject = IIf(Left(InvNum, 3) = "DBB", "Canal boat booking conformation for day hire on " & Format$(dateofhire, "dddd dd mmmm yyyy", 0, 0), "Canal boat booking conformation for evening hire on " & Format$(dateofhire, "dddd dd mmmm yyyy", 0, 0)) & " with Ellerbeck Narrowboats."
    .Body = Body1 & DDline & Body2 & DDline & Body3 & DDline & Body4 & DDline & Body5
    ' .HTMLBody = "<HTML><BODY><p>rs(""Dear"")</p><p>Many thanks for confirming your booking with us by paying the deposit of " & Format$(PaidAmount, "£#,##0.00", 0, 0) & " by card over the phone.</p><p> Please find attached your booking confirmation which you should print off and have with you on the day of hire.</p><p>If you cannot view the attached booking confirmation please visit <a href=""http://www.adobe.com/UK"">Adobe UK</a> to download the free Adobe Reader.</p><p> I have your card receipt here, if you would like it for your records please remind me for it on the day of hire.</p><p> You can follow us on <a href=""www.twitter.com/ellerbecknb"">Twitter</a> or become a fan on <a href=""www.facebook.com/boatstohire"">Facebook</a> (Please select the 'Like' button). Your comments and photos on board would be much appreciated either from your mobile devices on board, or your computer when you get home.<p>Regards,</p> <p>Mark</p> </BODY></HTML>"
    .Display
    End With

    '**closes outlook
    Set objEmail = Nothing
    'objOutlook.Quit


    ****** End of coding ******

    This is the first time i've ever posted anything on a forum so if you need more info then let me know. Thanks again in advance.

    Lucien (pbmech)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width