0
我已經實現了一個宏在Outlook電子郵件中的任何超鏈接之前追加一個字符串。然而,我把一個域名白名單工作正常,例如,如果我將https://google.com列入白名單,那麼除了https://google.com/etc ..以及其後的任何內容,它都會將其列入白名單。白名單所有子域名VBA宏
我的問題是,如果有人想訪問https://mail.google.com或任何其他子域,它將無法正常工作,並將其附加到APPEND_THIS_https://mail.google.com。我如何允許所有子域名在白名單中?
Dim myStr As String
Dim myURL As String
' Declare whitlist URL variables
'Dim whiteURL01 As String
'Dim whiteURL02 as string
myURL = "APPEND_THIS_"
' Add URLs to whitelist here
whiteURL01 = "https://google.com"
' Store the HTML Bodyin a variable
myStr = Msg.htmlbody
' Update all URLs
myStr = Replace(myStr, "href=""", "a href=" & myURL, , , vbTextCompare)
' Process whitelist
myStr = Replace(myStr, myURL & whiteURL01, whiteURL01, , , vbTextCompare)
' Assign back to HTML Body
Msg.htmlbody = myStr
' Save the mail
Msg.Save
太好了!!!正是我在找什麼!它根據需要運行2件事。 1-如何阻止它附加郵件到鏈接2-我試過mailgoogle.com,它沒有追加它。我希望它不會附加google.com或xxx.google.com,以免其他虛假域名不經過。再次感謝你! – user3454329
另外,它還附加了一個「之前的HREF例如APPEND_THIS_」http://...等 – user3454329
偉大的工作。爲了您的第一條評論,只需將白名單中的域名更改爲「.google.com」即可。 (之前添加點)。 – Fredrik