aniaaneczka
Member
- OS Version(s)
- Windows
- Outlook version
- Outlook 365 64 bit
- Email Account
- Office 365 Exchange
Operating system:: Windows 10
Outlook version: classic Outlook
Email type or host: Microsoft 365
Outlook version: classic Outlook
Email type or host: Microsoft 365
Hi,
I need to have a link from a specific sender open automatically in Firefox when the email is received.
This is the macro I am testing. It is probably a mess.
I get a Compile error with "unexpected identifier" pointing to the line Sub OpenLinksMessage().
Can anyone tell me how to get the macro work?
Private Declare PtrSafe Function ShellExecute _
Lib "shell32.dll" Alias "ShellExecuteA" ( _
ByVal hWnd As Long, _
ByVal Operation As String, _
ByVal Filename As String, _
Optional ByVal Parameters As String, _
Optional ByVal Directory As String, _
Optional ByVal WindowStyle As Long = vbMinimizedFocus _
) As Long
Sub OpenLinksMessage()
Dim olMail As Outlook.MailItem
Dim Reg1 As RegExp
Dim M1 As MatchCollection
Dim M As Match
Dim strURL As String
Dim lSuccess As Long
Set olMail = Application.Firefox().Selection(1)
Set Reg1 = New RegExp
With Reg1
.Pattern = "(https?[:]//([0-9a-z=\?:/\.&-^!#$%;_])*)"
.Global = False
.IgnoreCase = True
End With
if item.senderemailaddress = "someone@something.com" then
Set M1 = Reg1.Execute(olMail.Body)
For Each M In M1
strURL = M.SubMatches(0)
Debug.Print strURL
If InStr(strURL, "unsubscribe") Then GoTo NextURL
If Right(strURL, 1) = ">" Then strURL = Left(strURL, Len(strURL) - 1)
lSuccess = ShellExecute(0, "Open", strURL)
DoEvents
NextURL:
Next
End If
End if
Set Reg1 = Nothing
End Sub
I need to have a link from a specific sender open automatically in Firefox when the email is received.
This is the macro I am testing. It is probably a mess.
I get a Compile error with "unexpected identifier" pointing to the line Sub OpenLinksMessage().
Can anyone tell me how to get the macro work?
Private Declare PtrSafe Function ShellExecute _
Lib "shell32.dll" Alias "ShellExecuteA" ( _
ByVal hWnd As Long, _
ByVal Operation As String, _
ByVal Filename As String, _
Optional ByVal Parameters As String, _
Optional ByVal Directory As String, _
Optional ByVal WindowStyle As Long = vbMinimizedFocus _
) As Long
Sub OpenLinksMessage()
Dim olMail As Outlook.MailItem
Dim Reg1 As RegExp
Dim M1 As MatchCollection
Dim M As Match
Dim strURL As String
Dim lSuccess As Long
Set olMail = Application.Firefox().Selection(1)
Set Reg1 = New RegExp
With Reg1
.Pattern = "(https?[:]//([0-9a-z=\?:/\.&-^!#$%;_])*)"
.Global = False
.IgnoreCase = True
End With
if item.senderemailaddress = "someone@something.com" then
Set M1 = Reg1.Execute(olMail.Body)
For Each M In M1
strURL = M.SubMatches(0)
Debug.Print strURL
If InStr(strURL, "unsubscribe") Then GoTo NextURL
If Right(strURL, 1) = ">" Then strURL = Left(strURL, Len(strURL) - 1)
lSuccess = ShellExecute(0, "Open", strURL)
DoEvents
NextURL:
Next
End If
End if
Set Reg1 = Nothing
End Sub