Hey guys,
I am looking for a script that will parse emails coming in from a specified account and open the links automatically as they come in.
(I know i know not best practice, but i will code security checks into the script once I get it working, ( alter the regex to ONLY open links from the trusted domain etc...)
it should also open the links in a "New Tab" rather then a new instance of the browser.
Currently i am using this script found Here http://www.slipstick.com/developer/c...email-message/
Public Sub OpenLinks(olMail As Outlook.MailItem)
Dim Reg1 As RegExp
Dim M1 As MatchCollection
Dim M As Match
Dim strURL As String
Dim oApp As Object
Set oApp = CreateObject("InternetExplorer.Application")
Set Reg1 = New RegExp
With Reg1
.Pattern = "(https?[:]//([0-9a-z=\?:/\.&-^!#$;_])*"
.Global = False
.IgnoreCase = True
End With
If Reg1.test(olMail.Body) Then
Set M1 = Reg1.Execute(olMail.Body)
For Each M In M1
strURL = M.SubMatches(0)
Debug.Print strURL
'wait for page to load before passing the web URL
Do While oApp.Busy
DoEvents
Loop
oApp.navigate strURL
oApp.Visible = True
Next
End If
Set Reg1 = Nothing
Set oApp = Nothing
End Sub
The script will run properly if i run it manually ( The first link in the body does in fact open with IE. (and sound is played see below) )
But i can't get it to work on incoming message trigger.. ( But i do know the overall rule is working as i have it play a sound as well as run the VBA script. the sound plays but the link never opens in a window)
this is for alerts we get from a piece of equipment that sends email reports that only has a link to the web based report in the subject line. i am trying to skip having to check and open all the links manually. ( They are security cam alerts )
Thanks in advance
Jamie
Bookmarks