Hi there
Here is a script for Outlook 2010 to click on the first hyperlink in an email. It shows up as a script in the rules in outlook - the macro appears in the developer tab in Macros and runs fine but it will not trigger live. Any help would be much appreciated
'Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Sub LaunchURL(Itm As Outlook.MailItem)
Set objOL = Application
Set objDoc = objOL.ActiveInspector.WordEditor
Set objSel = objDoc.Windows(1).Selection
objDoc.Hyperlinks(1).Follow
Set Itm = Nothing
Set objOL = Nothing
Set objDoc = Nothing
Set objSel = Nothing
End Sub
Sub LoopThruEmails()
Dim i As Long
Dim InboxItems As Outlook.Items
Dim thisEmail As Outlook.MailItem
Set InboxItems = GetItems(GetNS(GetOutlookApp), olFolderInbox)
' assume there are inbox items
For i = InboxItems.Count To 1 Step -1
If TypeName(InboxItems.Item(i)) = "MailItem" Then ' it's an email
Set thisEmail = InboxItems.Item(i)
thisEmail.Display
' Sleep (3000) ' wait 3 seconds
Dim currItem As Outlook.MailItem
Dim Insp As Outlook.Inspector
Set currItem = Application.ActiveInspector.CurrentItem
LaunchURL currItem
thisEmail.Close olDiscard
Exit Sub
End If
Next i
End Sub
Function GetOutlookApp() As Outlook.Application
' returns reference to native Application object
Set GetOutlookApp = Outlook.Application
End Function
Function GetNS(ByRef app As Outlook.Application) As Outlook.NameSpace
Set GetNS = app.GetNamespace("MAPI")
End Function
Function GetItems(olNS As Outlook.NameSpace, folder As OlDefaultFolders) As Outlook.Items
Set GetItems = olNS.GetDefaultFolder(folder).Items
End Function
Regards Paul Fone
Here is a script for Outlook 2010 to click on the first hyperlink in an email. It shows up as a script in the rules in outlook - the macro appears in the developer tab in Macros and runs fine but it will not trigger live. Any help would be much appreciated
'Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Sub LaunchURL(Itm As Outlook.MailItem)
Set objOL = Application
Set objDoc = objOL.ActiveInspector.WordEditor
Set objSel = objDoc.Windows(1).Selection
objDoc.Hyperlinks(1).Follow
Set Itm = Nothing
Set objOL = Nothing
Set objDoc = Nothing
Set objSel = Nothing
End Sub
Sub LoopThruEmails()
Dim i As Long
Dim InboxItems As Outlook.Items
Dim thisEmail As Outlook.MailItem
Set InboxItems = GetItems(GetNS(GetOutlookApp), olFolderInbox)
' assume there are inbox items
For i = InboxItems.Count To 1 Step -1
If TypeName(InboxItems.Item(i)) = "MailItem" Then ' it's an email
Set thisEmail = InboxItems.Item(i)
thisEmail.Display
' Sleep (3000) ' wait 3 seconds
Dim currItem As Outlook.MailItem
Dim Insp As Outlook.Inspector
Set currItem = Application.ActiveInspector.CurrentItem
LaunchURL currItem
thisEmail.Close olDiscard
Exit Sub
End If
Next i
End Sub
Function GetOutlookApp() As Outlook.Application
' returns reference to native Application object
Set GetOutlookApp = Outlook.Application
End Function
Function GetNS(ByRef app As Outlook.Application) As Outlook.NameSpace
Set GetNS = app.GetNamespace("MAPI")
End Function
Function GetItems(olNS As Outlook.NameSpace, folder As OlDefaultFolders) As Outlook.Items
Set GetItems = olNS.GetDefaultFolder(folder).Items
End Function
Regards Paul Fone