• How to find hyperlinks in an email?

    Author
    Topic
    #472373

    I have inadvertently changed the font color of a large email, saved [/u]it, and exited.

    The problem is that I have many hyperlinks in that document that are no longer apparent.

    Is there a way to open that email, search for those hyperlinks, and when found, change the text’s color to that of normal hyperlink (blue)?

    Viewing 4 reply threads
    Author
    Replies
    • #1250477

      Hyperlinks are often underlined, so that may be a starting point. Failing that I would view the raw email and search for “<a " or "http://&quot;. Find the matching text before " ” and return to the email and search for the matching text.
      Tell us what mail client you use and we can advise how to view the raw mail.

      cheers, Paul

    • #1250479

      Hi Paul — when I changed the font color, I also removed any/all bold/underline/italics, so if you were to view it, it looks like a pure text email, but it isn’t.

      I am using Outlook 2010 x86.

      Thanks.

    • #1250484

      I think (can’t test it here ’cause I don’t use OL on this machine) if you highlight the entire email (Ctrl A) then right click and select view source, you will be able to see the HTML content.

      cheers, Paul

      • #1250500

        I think (can’t test it here ’cause I don’t use OL on this machine) if you highlight the entire email (Ctrl A) then right click and select view source, you will be able to see the HTML content.

        Good idea, but there isn’t an option to view source viewing an Outlook email. I would surmise, though, that saving the email as an HTML/MHT file would allow me to see that code.

        Unfortunately, there are too many hyperlinks to do this manually.

    • #1250522

      Is there a way to open that email, search for those hyperlinks, and when found, change the text’s color to that of normal hyperlink (blue)?

      I developed and tested this in Outlook 2007. Only tried one example, but it seemed to work in this scenario: forward HTML message, select all and choose a color, then run the macro to de-color the links.

      Code:
      Sub StripSpansFromLinks()
      ' Retrieve HTML body for active message
      Dim msg As Outlook.MailItem, strBod As String
      Set msg = ActiveInspector.CurrentItem
      strBod = Replace(msg.HTMLBody, vbCrLf, " ")  ' Convert line breaks to single space
      strBod = WildReplace(strBod, "s+", " ")  ' Convert all whitespace to single space
      'Debug.Print strBod
      'Stop
      ' Examine links in the HTML body
      Dim lngPos As Long, lngPosEnd As Long, strTemp As String
      lngPos = 1
      Do
          lngPos = InStr(lngPos, strBod, "<a ", vbTextCompare)
          If lngPos = 0 Then Exit Do
          lngPosEnd = InStr(lngPos, strBod, "", vbTextCompare)
          ' Create temp string of the link
          strTemp = Mid(strBod, lngPos, lngPosEnd - lngPos + 4)
          ' Rip out any  and  tags
          strTemp = WildReplace(strTemp, "]*>", "")
          strTemp = WildReplace(strTemp, "", "")
          ' insert modified string back into the body string
          strBod = Left(strBod, lngPos - 1) & strTemp & Mid(strBod, lngPosEnd + 4)
          lngPos = lngPos + 3
      Loop
      'Debug.Print strBod
      'Stop
      ' Rewrite the HTML body
      msg.HTMLBody = strBod
      Set msg = Nothing
      End Sub
      
      Private Function WildReplace(strExpression As String, strFind As String, _
          strReplace As String, Optional bolReplaceAll As Boolean = True, _
          Optional bolCaseSensitive As Boolean = False) As String
        If (strExpression = vbNullString) Or (strFind = vbNullString) Then
          WildReplace = strExpression
          Exit Function
        End If
      
        Dim objregexp As Object
        'instantiate regexp object
        Set objregexp = CreateObject("vbscript.regexp")
        objregexp.IgnoreCase = Not bolCaseSensitive
        objregexp.Global = bolReplaceAll
        ' Pattern syntax: Visual Basic Scripting Edition-Pattern Property
        objregexp.Pattern = strFind
        
        'outer lines temporarily replace the line feeds to avoid the wildcard search tripping on them
        strExpression = Replace(strExpression, vbCrLf, "zxzx")
          strExpression = objregexp.Replace(strExpression, strReplace)
        WildReplace = Replace(strExpression, "zxzx", vbCrLf)
        
        Set objregexp = Nothing
      End Function
      • #1250545

        I developed and tested this in Outlook 2007. Only tried one example, but it seemed to work in this scenario: forward HTML message, select all and choose a color, then run the macro to de-color the links.

        Thanks, jscher2000. Will give it a try during the week and let you know how I made out. Appreciate it.

        One thought, though. What do I get by forwarding the email, instead of simply editting it? The email was saved and is in the Drafts folder.

        • #1250556

          What do I get by forwarding the email, instead of simply editting it? The email was saved and is in the Drafts folder.

          I just needed something to work with. I don’t usually compose lengthy HTML messages.

          • #1250590

            I just needed something to work with. I don’t usually compose lengthy HTML messages.

            Ah. So I need not do a forward. Gotcha, and thanks.

    • #1250621

      This would work to get you back to the original text color with the formatted hyperlinks (in Outlook 2007, so I’m guessing it might be the same in 2010), but you will lose the formatting you applied through out the email. So it may not work for what you need if you are concerned about changing everything back to where it started sans-formatting.

      Highlight all the text, go to the Format Text tab, Click on Quick Styles and choose Clear Formatting.

    Viewing 4 reply threads
    Reply To: Reply #1250479 in How to find hyperlinks in an email?

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information:




    Cancel