How to run a URL when an email arrives

I would like to run the url when the email arrives in Outlook. I set the rule and run the script function. It looks like I want to call ShellExecute to launch the URL in the browser, but when I hit this line:

    ShellExecute(0&, "open", URL, vbNullString, vbNullString, _
vbNormalFocus)

The method is not defined. Any ideas?

+3
source share
5 answers

ShellExecute is a feature in windows dll. You need to add an ad for it, like this in a VBA module:

Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
    ByVal hWnd As Long, _
    ByVal lpOperation As String, _
    ByVal lpFile As String, _
    ByVal lpParameters As String, _
    ByVal lpDirectory As String, _
    ByVal nShowCmd As Long) As Long      

Shell ShellExecute , ShellExecute URL-, . IE. IE. iexplore.exe . ShellExecute url windows.

+4

Followhyperlink VBA, URL- . , .

+2

, :

start http://someurl.com/?a=1^&b=2

And you configure the Outlook rule to run this batch file. Note the ^ sign before &. This is an escape sequence for and in batch files. Also note that you need to install the default browser on Windows, there is an almost 100% chance that you have one.

+1
source
Shell ("CMD /C start http://www.spamcop.net"), vbNormalFocus
+1
source

Alternatively, use Shellfor example:

Sub LaunchURL(Item As Outlook.MailItem)
    Shell ("C:\Program Files\Internet Explorer\IEXPLORE.EXE" & " " & Item.Body)
End Sub
0
source

Source: https://habr.com/ru/post/1704336/


All Articles