Automatically open link in email received

Nabeel Naveed

New Member
Outlook version
Outlook 2016 64 bit
Email Account
Office 365 Exchange
Hi! Diane, are you still around? I would like to ask that, can I use the same procedure and scripts for Gmail account?
 

Nabeel Naveed

New Member
Outlook version
Outlook 2016 64 bit
Email Account
Office 365 Exchange
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.
 

fmissana

New Member
Outlook version
Outlook on the web
Email Account
Office 365 Exchange
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?
 

fmissana

New Member
Outlook version
Outlook on the web
Email Account
Office 365 Exchange
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
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
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).
 

fmissana

New Member
Outlook version
Outlook on the web
Email Account
Office 365 Exchange
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
 

fmissana

New Member
Outlook version
Outlook on the web
Email Account
Office 365 Exchange
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?
 

GermanUSer

Member
Outlook version
Outlook 2016 64 bit
Email Account
Exchange Server
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!
 

GermanUSer

Member
Outlook version
Outlook 2016 64 bit
Email Account
Exchange Server
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
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
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
 

GermanUSer

Member
Outlook version
Outlook 2016 64 bit
Email Account
Exchange Server
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
 
Thread starter Similar threads Forum Replies Date
A How to open a specific link automatically with outlook 2016 Outlook VBA and Custom Forms 5
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
M In Outlook 2010, upon deleting an open e-mail, the next e-mail does not open automatically in full s Using Outlook 2
D Outlook 2010; How to set it to automatically open the next messsage Using Outlook 3
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 New Slipstick.com Articles 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 New Slipstick.com Articles 0
Cameron Piper Automatically update custom forms across multiple computers Outlook VBA and Custom Forms 1
N Automatically file email messages Using Outlook 2
J Automatically Move Old Items from a Shared Mailbox to a .PST on a Network Drive Outlook VBA and Custom Forms 1
M Change default "automatically test account settings when Next is clicked" Using Outlook 1
D Automatically file message and reply to folder. Using Outlook 1
A Code to automatically delete message after sending Outlook VBA and Custom Forms 6
Diane Poremsky Automatically Create Contacts From Messages New Slipstick.com Articles 1
T Outlook 2010 emails do not refresh automatically Exchange Server Administration 1
L Save Mail Message to new folder created automatically Outlook VBA and Custom Forms 1
G Hae Rules NOT perform automatically? Using Outlook 1
F Automatically close email after selecting mark unread Using Outlook 1
nathandavies How to save emails to a specific folder on a network automatically using a macro Outlook VBA and Custom Forms 14
T Default inbox not automatically sending/receiving Using Outlook 1
Angger Microsoft Outlook 2010 Automatically Restarting Using Outlook 2
N Outlook Shared appointments automatically to Private Calendar Using Outlook 1
M Automatically move Outlook message to the specific folder when click on reply to all Using Outlook 4
Similar threads


















































Top