Outlook VBA Change/Replace Hyperlinks Before Sending

BAlGaInTl

Well-known Member
Joined
May 7, 2003
Messages
1,082
Hello,

I don't normally venture in to Outlook programming, but I have a problem I'm trying to solve. My organization recently enabled ATP for incoming outlook email links from external sources. So now, when I reply to an email, or forward it internally, identifying information remains in place in a "Safe Link" from Microsoft. This adds extra difficulty in the fact that sometimes, the links simply do not work after conversion.

Not a huge deal, but it bugs me since links I forward now have my email address attached.

So I found the following code that successfully replaces the Address property of hyperlinks. I'm calling it from another macro that runs before I send an email and checs to see if there are any "safe" links:

Code:
Sub HyperLinkChange()
Dim objDoc As Object
Dim tmpLink As Object
    On Error Resume Next
    If ActiveInspector.EditorType = olEditorWord Then
        ' use WordEditor Inspector
        Set objDoc = ActiveInspector.WordEditor
        For Each tmpLink In objDoc.Hyperlinks
            tmpLink.Address = "Hyper Link Removed. Please copy and paste into your browser to view"
        Next tmpLink
    End If
End Sub

I wanted to expand on this, and only run the code to replace if it's actually an ATP Safe Link.

I found that if I use something like

Code:
response = msgbox(tmpLink.Address)

a dialog box is presented with the link. But if I try to evaluate tmpLink.Address as a string, it's just blank.

Is there a way to convert tmpLink.Address in this situation to a string that can be evaluated?

ETA: I cross-posted this to the VBAExpress forums since they have an Outlook specific forum.

http://www.vbaexpress.com/forum/showthread.php?65114-Convert-Hyperlink-Address-Property-to-Text
 
Last edited:

Some videos you may like

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

Watch MrExcel Video

Forum statistics

Threads
1,122,583
Messages
5,597,023
Members
414,116
Latest member
sfullnet

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top