单击Outlook电子邮件正文中的超链接的Anchor文本

时间:2014-07-31 00:04:29

标签: vba outlook

我发现这个脚本会在Outlook电子邮件正文中搜索超链接并将其打开。问题是收到的电子邮件有锚文本而不是整个超链接,我不能让它点击锚文本。任何建议。万分感谢

Sub LaunchURL(Itm As Outlook.MailItem)

    Dim bodyString As String

    Dim bodyStringSplitLine

    Dim bodyStringSplitWord

    Dim SplitLine

    Dim SplitWord 

    bodyString = Itm.Body

    bodyStringSplitLine = Split(bodyString, vbCrLf)

    For Each SplitLine In bodyStringSplitLine

        bodyStringSplitWord = Split(SplitLine, " ")

        For Each SplitWord In bodyStringSplitWord

            If Left(SplitWord, 7) = "http://" Then

                Shell ("C:\Program Files\Internet Explorer\IEXPLORE.EXE" & " " & SplitWord)

            End If

        Next

    Next

    Set Itm = Nothing

End Sub

1 个答案:

答案 0 :(得分:0)

LaunchURL代码专门用于URL可见的地方,例如它是纯文本邮件。

隐藏链接的位置,您可以选择文本并将其带到Word Hyperlink.Follow Method


编辑:发现更简单,不要去Word。

Public Sub FollowLinkAddress(itm As Outlook.MailItem)

Dim oDoc As Object
Dim h

Set itm = ActiveInspector.CurrentItem

If itm.GetInspector.EditorType = olEditorWord Then

    Set oDoc = itm.GetInspector.WordEditor

    For Each h In oDoc.Hyperlinks
        h.Follow
    Next

End If

End Sub