How to Auto Open All Embedded Hyperlinks when Reading Specific Emails in Outlook

Some users desire that Outlook can automatically open the hyperlinks inserted in the email body when they open and read specific emails. Now, in this article, we will share a method which can realize it with ease.

When opening and reading specific emails, such as vitally important emails from your boss, if the emails contain several hyperlinks, you will definitely open these links. In comparison with opening the embedded hyperlinks manually, making Outlook auto open them will surely be much more convenient. Here we will teach you how to achieve it in detail.

Auto Open All Embedded Hyperlinks when Reading Specific Emails

Auto Open All Embedded Hyperlinks when Reading Specific Emails

  1. To start with, launch the Outlook application.
  2. After entering Outlook window, press “Alt + F11” key shortcuts.
  3. In the subsequent VBA editor window, you need enable “Microsoft VBScript Regular Expressions” object. Hit ‘Tools” and select “References” to achieve it.
  4. Next, open the “ThisOutlookSession” project.
  5. Then, copy the following VBA code into this project.
Public WithEvents objInspectors As Outlook.Inspectors
Public WithEvents objMail As Outlook.MailItem

Private Sub Application_Startup()
 Set objInspectors = Outlook.Application.Inspectors
End Sub

Private Sub objInspectors_NewInspector(ByVal Inspector As Inspector)
 If Inspector.CurrentItem.Class = olMail Then
 Set objMail = Inspector.CurrentItem
 End If
End Sub

Private Sub objMail_Open(Cancel As Boolean)
    Dim objRegExp As RegExp
    Dim objMatches As MatchCollection
    Dim objMatch As match
    Dim strURL As String
 
    'When opening specific emails
    'From specific persons or marked as important
    If objMail.SenderEmailAddress = "boss@datanumen.com" And objMail.Importance = olImportanceHigh Then
       Set objRegExp = New RegExp
 
       With objRegExp
            .Pattern = "(([0-9a-z=\?:/\.&-^!#$;_])*)"
            .Global = True
            .IgnoreCase = True
       End With

       If objRegExp.Test(objMail.Body) Then

          Set objMatches = objRegExp.Execute(objMail.Body)
          For Each objMatch In objMatches
              strURL = objMatch.SubMatches(0)
 
              'Exclude hyperlinks of email addresses
              If InStr(strURL, "@") = 0 Then
 
                 'Get the Internet Explorer
                 'Change the path as per your own case
                 Shell (Chr(34) & "C:\Program Files\Internet Explorer\iexplore.exe" & Chr(34) & strURL)
                 DoEvents
              End If
          Next
       End If
    End If
End Sub

VBA Code - Auto Open All Embedded Hyperlinks when Reading Specific Emails

  1. After that, you ought to sign this macro. Click “Tools” > “Digital Signature” to accomplish it.
  2. Next, exit the current window and change your Outlook macro settings.
  3. Ultimately, you need to restart your Outlook to enable the new VBA project.
  4. Since then, every time when you double click on the specific emails to read it in its own Message window, Outlook will auto recognize the hyperlinks in the email body and immediately open them in Internet Explorer.

Never Bypass Outlook Errors

Perhaps you have been subject to assorted Outlook errors. Although eliminating Outlook issues is difficult, you can’t disregard them either. Accumulated errors can lead to serious disasters in Outlook, such as PST damage. Hence, you’d better prepare a formidable external Outlook fix utility, like DataNumen Outlook Repair. It can minimize corruption, thereby extracting maximum PST data with no fuss.

Author Introduction:

Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including corrupted mdf and outlook repair software products. For more information visit www.datanumen.com

Comments are closed.