Automatically open link in email received

Status
Not open for further replies.
Hi! Diane, are you still around? I would like to ask that, can I use the same procedure and scripts for Gmail account?
 
Most of the time, yes. :)


As long as its in outlook, yes. If you are using automation to open the links and gmail is not the default account, you need to reference it, but its not difficult.

Thanks, I will try to implement this procedure for Gmail if need help will you able to assist me that would be a great favor.
 
Hi All,

I am a freelancer agent and I am less than a novice when it comes to coding so I need some help please. I receive jobs via email which contains 2 links. 1 to accept the job and the 2nd is to decline it.

As I am on the road it is difficult getting reception and checking emails every few minutes so I need a script that runs on my PC as outlook 2007 is always open, that will automatically click on the "accept" link. I have tried running rules, by detecting key words in the incoming message, but the only option I have is to run a script and I am hopeless at that sort of thing. I am happy to pay for the script through PayPal, it's just that I have a very small window of opportunity to accept the job in.

Any help would be greatly appreciated, thanks.

brilliant. It took me a while to figure out the shell command and having to remove the reference to IE, silly me. I told you I am less than novice when it comes to this sort of thing. I don't know how to thank you, you have been a blessing, thank you so much for taking the time and I am sorry if I caused any stress, God bless you I know I felt it.

Kindest Regards
Tony
Hello Tony, sounds like you are getting the same type of emails like I do (accept/decline, short time window). Do you mind sharing the steps and code you got in order to accept the jobs?
 
Hello Diane, as indicated I have a very similar problem as Tony (clicking on a specific link in an email to open a web page and then clicking on a radio button on that page to accept the job). As you indicated, I copy pasted the Open a specific hyperlink code in the ThisOutlookSession window, but when I run it, I get a compile error "sub or Function not defined" and the cursor highlights ShellExecute in the line starting with 1success. Do I need to add/modify anything?
Awaiting your kind response.
BR
 
Did you add a reference to the Microsoft VBScript Regular Expressions library in Tools, References? (Error is usually earlier if you didn't)

Do you use outlook 64-bit? (error should be at the start though).
 
Did you add a reference to the Microsoft VBScript Regular Expressions library in Tools, References? (Error is usually earlier if you didn't)
> yes, I did
Do you use outlook 64-bit? (error should be at the start though).
> yes, I do
 
Hello Diane, I figured out what the problem was. In the "Open a specific hyperlink" code you suggested, there is a portion for 64bit Outlook versions that is commented out:
' 64bit office use: Private Declare PtrSafe Function ShellExecute _
Private Declare 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

Since I am using a 64bit versin, I added PrtSafe after Declare in the second line, but I failed to delete the underscore at the end of the first line. So VBA was taking the whole thing as a comment and was not seeing the declaration of the ShellExecute function.

I took out the underscore at the end of the first line and now I no longer get the "sub or Function not defined" error.

However, the script is not doing anything. What Am I missing?
 
Hello Diane,
I'm trying to get the script to running. The first link in the message must be clicked.
Unfortunately, it does not work or only partially. Is there any way to contact you via conversation or mail to explain it better?
I would be very grateful for your help!
 
probably somebody can help me to..
macro work for test, but i cant build a rule, scriptlist is empty..? i have screenshot here
any ideas please..?

Unbenannt.PNG
 
What exactly is happening - it works on some but not all messages? Any errors?

On the rule, the macro "title" needs to be formatted like this - specifically the bolded part.
Public Sub OpenLinks(olMail As Outlook.MailItem)

I have a macro that can work for testing, in place of a rule - select a message and run this macro. It will run the other macro.

Code:
Sub TestRunScript()
Dim objApp As Outlook.Application
Dim objItem As MailItem
Set objApp = Application
Set objItem = objApp.ActiveExplorer.Selection.Item(1)

'macro name you want to run goes here
OpenLinks objItem

End Sub
 
Thanks for the answer!
Would you please help me further? The task is this: with new e-mail the first hyperlink must be opened. I have tried several scripts that are described here. But I do not get the job completely solved. I made that when testing the script works in VBA. But I can not run the script with Rule, because the script list stays empty, like in the picture. Or I can not test the script because the script name is missing. I have no idea how it works and try to copy / paste, but I can not get it. I tried that
Is it possible to contact you for help? probably with team viewer?
Many thanks





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.ActiveExplorer().Selection(1)

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
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

Set Reg1 = Nothing
End Sub
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
A How to open a specific link automatically with outlook 2016 Outlook VBA and Custom Forms 6
A How to open a specific link automatically with outlook Outlook VBA and Custom Forms 13
W Automatically open attachments without automatically printing them Using Outlook 0
X Run macro automatically when a mail appears in the sent folder Using Outlook 5
J Calendar events created on iPhone automatically changing default alert from 'None' to 'Time of Event' Using Outlook.com accounts in Outlook 0
Z Automatically adjust Outlook Reading Pane from bottom to right depending on portrait or landscape window Using Outlook 1
G Automatically delete email when a condition is met Outlook VBA and Custom Forms 1
Hornblower409 Automatically or Manually Backup Multiple Versions of VbaProject.OTM Outlook VBA and Custom Forms 1
B Outlook 2019 Automatically move email after assigning category Using Outlook 4
G automatically choosing "add to autocorrect" option Using Outlook 0
L Why are some email automatically going to "archive" Using Outlook 2
Z Outlook 365 Automatically assign categories to incoming mail in a shared folder Round Robin Outlook VBA and Custom Forms 1
G Automatically delete messages in the synchronization folder Outlook VBA and Custom Forms 3
C Automatically Insert Recipient Name from To Field Outlook VBA and Custom Forms 4
E Remove flag automatically Using Outlook 4
T Outlook 365 Move newly created tasks automatically on save. Outlook VBA and Custom Forms 1
M Outlook 365 Switching from AOL to Yahoo automatically Using Outlook 5
P Print attachments automatically and move the mail to an existing folder called "Ted" Outlook VBA and Custom Forms 4
B Zoom automatically next email item (VBA) Outlook VBA and Custom Forms 2
Paul Hobbs Automatically accept "Empty Folders" prompt Outlook VBA and Custom Forms 6
diver864 vba for a rule to automatically accept meeting requests with 'vacation' in subject, change to all-day event, change to free, don't send reply Outlook VBA and Custom Forms 1
D Custom Search Folders not refreshing/updating automatically Using Outlook 0
M Automatically add senders first name to a greeting Outlook VBA and Custom Forms 1
C Add Form to Appointments Received, Automatically Outlook VBA and Custom Forms 6
J Automatically forward email and apply template Outlook VBA and Custom Forms 0
Y Outlook 2013 Stop Outlook from automatically assigning categories to Tasks Using Outlook 0
O Forward a email with modified body Automatically. Outlook VBA and Custom Forms 0
P Automatically Categorize Meetings once they are accepted Outlook VBA and Custom Forms 5
N How to set automatically the default or user defined Quickstyle Templates by Answer in Outlook Using Outlook 1
O Run macro automatically at sending an email Using Outlook 11
D Outlook 2016 automatically increment anniversaries Using Outlook 1
T Office 2013 no longer updating automatically Using Outlook 2
B Automatically Forward Emails and Remove/Replace All or Part of Body Outlook VBA and Custom Forms 8
D Print attachments automatically and moves the mail to a new folder Outlook VBA and Custom Forms 9
L Automatically Insert Recipient Name from To Field Outlook VBA and Custom Forms 33
N how to sync automatically when outlook opens Using Outlook 10
A Sort emails into subfolders based on sender and deleting emails automatically Outlook VBA and Custom Forms 3
undercover_smother Automatically Forward All Sent Mail and Delete After Send Outlook VBA and Custom Forms 10
C Need VBA code to automatically save message outside outlook and add date Outlook VBA and Custom Forms 1
stephen li VBA Outlook send mail automatically by specified outlook mail box Outlook VBA and Custom Forms 1
R Make Enter Network Password Prompt Go Away Automatically Using Outlook 0
I Print Automatically Attachments Outlook VBA and Custom Forms 3
S Automatically selecting folders and deleting messages in Outlook VBA Outlook VBA and Custom Forms 7
M Outlook 2016 Rules Not Working Automatically Using Outlook 5
Diane Poremsky Automatically create a task when sending a message Using Outlook 0
D Is it possible to automatically send an email when it is moved to a folder? Exchange Server Administration 1
A Automatically send email based on drop-down field? Outlook VBA and Custom Forms 2
M Automatically create event in calendar when task is created Outlook VBA and Custom Forms 1
Diane Poremsky Create Appointment From Email Automatically Using Outlook 0
Cameron Piper Automatically update custom forms across multiple computers Outlook VBA and Custom Forms 1

Similar threads

Back
Top