+ Reply to Thread
Results 1 to 5 of 5

Need Help with HTMLBody. Hyperlink email address and web address in body message VBA

  1. #1
    Registered User
    Join Date
    09-22-2014
    Location
    Canada
    MS-Off Ver
    2010
    Posts
    11

    Wink Need Help with HTMLBody. Hyperlink email address and web address in body message VBA

    I feel like giving up. I just can't figure this out or find clear examples that can apply to my VBA. Everything works with a basic message, just not when I try to hyper-link the body of the message. If you could provide any help or know how to simply solve this issue, I would be sooo grateful.

    The issue: I am attempting to Hyper-link a particular email address, for arguments sake, [email protected] within the body of the Email Message as seen below and hyper-link the email address to the words "contact us." Furthermore, I am attempting to hyper-link a web address to the words "Lean Website" and a different one for "White Belt Report."

    You can see in the following lines that I've included 'with hyperlink url to > to the word or email I would really love to be hyperlinked, for explanation purposes only. If you could delete them, and leave only the hyperlinked word that would be great.



    Sub Test2()
    Dim OutApp As Object
    Dim OutMail As Object
    Dim cell As Range

    Application.ScreenUpdating = False
    Set OutApp = CreateObject("Outlook.Application")

    On Error GoTo cleanup
    For Each cell In Range("Q1:Q" & Cells(Rows.Count, "Q").End(xlUp).Row)
    If cell.Value Like "?*@?*.?*" And _
    LCase(Cells(cell.Row, "R").Value) = "yes" _
    And LCase(Cells(cell.Row, "S").Value) <> "sent" Then

    Set OutMail = OutApp.CreateItem(0)

    strbody = "Hello " & Cells(cell.Row, "P").Value & "<br>" _
    & "<br>" _
    & "Line 1" & "<br>" _
    & "<br>" _
    & "Line 2" & "<br>" _
    & "<br>" _
    & "Line 4 'with hyperlink url to > Lean Website" & "<br>" _
    & "<br>" _
    & "Line 5" & "<br>" _
    & "<br>" _
    & "Line 6" & "<br>" _
    & "<br>" _
    & "Steps:" & "<br>" _
    & " 1. Document your report using the 'with hyperlink url to > White Belt Report" & "<br>" _
    & "" & "<br>" _
    & " 2. Review with supervisor" & "<br>" _
    & "" & "<br>" _
    & " 3. Forward your White Belt Report to and any questions 'with hyperlink to email > [email protected] & " < br > "" _
    & "" & "<br>" _
    & "If you need any assistance, feel free to 'with hyperlink to email [email protected] > contact us"

    On Error Resume Next
    With OutMail
    .To = cell.Value
    .CC = ""
    .BCC = ""
    .Subject = "Report Reminder"
    .HTMLBody = strbody

    .Display
    End With
    On Error GoTo 0
    Cells(cell.Row, "S").Value = "sent"
    Set OutMail = Nothing
    End If
    Next cell

    cleanup:
    Set OutApp = Nothing
    Application.ScreenUpdating = True
    End Sub




    Thanks for taking the time to even read my issue, I just am not skilled enough for this.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Need Help with HTMLBody. Hyperlink email address and web address in body message VBA

    To add hyperlinks in HTML you need to use anchor tags.

    For example.
    HTML Code: 
    You need to construct the appropriate HTML in your code.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    09-22-2014
    Location
    Canada
    MS-Off Ver
    2010
    Posts
    11

    Re: Need Help with HTMLBody. Hyperlink email address and web address in body message VBA

    When I do that it always gives me an error message, either an expected end or a syntax. Could you possibly provide me an example through this following line, as I'm unsure of how to insert the anchor tags.

    & "Line 4 'with hyperlink url to > Lean Website" & "<br>" _

    If you cannot it is okay, I appreciate your tip and how quickly you responded.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Need Help with HTMLBody. Hyperlink email address and web address in body message VBA

    Can you post you used to try and incorporate links like those I posted?

    Also what error(s) did you receive?

  5. #5
    Registered User
    Join Date
    09-22-2014
    Location
    Canada
    MS-Off Ver
    2010
    Posts
    11

    Re: Need Help with HTMLBody. Hyperlink email address and web address in body message VBA

    Never-mind, I got it working. Long day yesterday and finally squeaked in some time to work on this (during a meeting lol).

    Thank you very much for your help!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 02-21-2013, 04:46 AM
  2. Replies: 1
    Last Post: 03-08-2012, 01:57 PM
  3. Replies: 6
    Last Post: 12-02-2011, 02:14 PM
  4. Excel Email: Address and portion of body in cell
    By pete3589 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-11-2005, 11:40 AM
  5. email address hyperlink
    By Ulti in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-01-2005, 12:06 AM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1