Open and Save Hyperlink Files in multiple emails

yaoxlin

Member
Outlook version
Outlook 2016 64 bit
Email Account
Office 365 Exchange
Hi, I'm very new to this VBA but have read Open All Hyperlinks in an Outlook Email Message posting. However, I'm looking for a way to open a very specific Hyperlink within an email usually following the word "Attachments" the name of the Hyberlinks differ each time. Or perhaps another way to go about is is to remove the other hyperlinks that don't pertain to the one I want by using this...
If Reg1.Test(olMail.Body) Then

Set M1 = Reg1.Execute(olMail.Body)
For Each M In M1
strURL = M.SubMatches(0)
If InStr(strURL, "unsubscribe") Then GoTo NextURL
If Right(strURL, 1) = ">" Then strURL = Left(strURL, Len(strURL) - 1
But I haven't been successful in removing the unwanted links

any help is much appreciated. Thanks!
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
The hyperlink url does not contain the word 'attachment' but the its in the message body?

This should do it, where "View this thread" is the pretty part of the hyperlink. It's under Open a specific hyperlink

With Reg1
.Pattern = "View this thread <(.*)>"
.Global = True
.IgnoreCase = True
End With

That code would open the link in this email message:
2747
 

yaoxlin

Member
Outlook version
Outlook 2016 64 bit
Email Account
Office 365 Exchange
My emails work the opposite... where I have 5-7 hyperlinks with names that doesn't change... but the attachment I want changes names ak the time.
 

yaoxlin

Member
Outlook version
Outlook 2016 64 bit
Email Account
Office 365 Exchange
What if I change the global = false for this that are always the same name per email. That should only open the ones that are not " view this thread"
 

yaoxlin

Member
Outlook version
Outlook 2016 64 bit
Email Account
Office 365 Exchange
Here is what I have:

Sub OpenLinksMessage(olMail As Outlook.MailItem)
Dim Reg1 As RegExp
Dim M1 As MatchCollection
Dim M As Match
Dim strURL As String

Dim browserPath As String
browserPath = Chr(34) & "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" & Chr(34)

Set Reg1 = New RegExp

With Reg1
.Pattern = "(https?[:]//([0-9a-z=\?:/\.&-^!#$%;_])*)"
.Global = True
.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)

With Reg1
.Pattern = "View online <(.*)>"
.Global = False
.IgnoreCase = True
End With

With Reg1
.Pattern = "View PDF <(.*)>"
.Global = False
.IgnoreCase = True
End With

With Reg1
.Pattern = "this short training video <(.*)>"
.Global = False
.IgnoreCase = True
End With

With Reg1
.Pattern = "support@procore.com <(.*)>"
.Global = False
.IgnoreCase = True
End With

With Reg1
.Pattern = "Support Home <(.*)>"
.Global = False
.IgnoreCase = True
End With
 

yaoxlin

Member
Outlook version
Outlook 2016 64 bit
Email Account
Office 365 Exchange
that didn't work...

I'm trying this but it's not working either.


Sub OpenLinksMessage(olMail As Outlook.MailItem)
Dim Reg1 As RegExp
Dim M1 As MatchCollection
Dim M As Match
Dim strURL As String

Dim browserPath As String
browserPath = Chr(34) & "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" & Chr(34)

Set Reg1 = New RegExp

With Reg1
.Pattern = "(https?[:]//([0-9a-z=\?:/\.&-^!#$%;_])*)"
.Global = True
.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)

If InStr(strURL, "View online") Then GoTo NextURL

If Right(strURL, 1) = ">" Then strURL = Left(strURL, Len(strURL) - 1)

Shell (browserPath & " -url " & strURL)
DoEvents

NextURL:
Next
End If

Set Reg1 = Nothing
End Sub

If InStr(strURL, "View PDF") Then GoTo NextURL

If Right(strURL, 1) = ">" Then strURL = Left(strURL, Len(strURL) - 1)

Shell (browserPath & " -url " & strURL)
DoEvents

NextURL:
Next
End If

Set Reg1 = Nothing
End Sub

If InStr(strURL, "this short training video.") Then GoTo NextURL

If Right(strURL, 1) = ">" Then strURL = Left(strURL, Len(strURL) - 1)

Shell (browserPath & " -url " & strURL)
DoEvents

NextURL:
Next
End If

Set Reg1 = Nothing
End Sub

If InStr(strURL, "Procore") Then GoTo NextURL

If Right(strURL, 1) = ">" Then strURL = Left(strURL, Len(strURL) - 1)

Shell (browserPath & " -url " & strURL)
DoEvents

NextURL:
Next
End If

Set Reg1 = Nothing
End Sub

If InStr(strURL, "support@procore.com") Then GoTo NextURL

If Right(strURL, 1) = ">" Then strURL = Left(strURL, Len(strURL) - 1)

Shell (browserPath & " -url " & strURL)
DoEvents

NextURL:
Next
End If

Set Reg1 = Nothing
End Sub

If InStr(strURL, "https://suport.procore.com") Then GoTo NextURL

If Right(strURL, 1) = ">" Then strURL = Left(strURL, Len(strURL) - 1)

Shell (browserPath & " -url " & strURL)
DoEvents

NextURL:
Next
End If

Set Reg1 = Nothing
End Sub
 
Outlook version
Outlook 2013 64 bit
Email Account
Exchange Server
Good morning.

My answer might be hiding inside the above options. I am just not seeing it, unfortunately. Let me explain what I'm seeking and ask that you point me in the right direction.

Thank you so much...really appreciate it!


Bob

I run Google Chrome with my Outlook 2013 64-bit.
The initial goal is to manually run a single script (VBA or other from the toolbar/ribbon) on a single email:

  1. Save Email Message itself (any format that makes sense...preference being .pdf).
  2. Save Linked Documents from Email Body - typically more than one with different files names.
  3. Avoid Saving Unwanted Links from Email Body (there is an image and a link to a .pdf handbook within each email).
  4. All of these items to be saved within a one folder per email.
  5. Folder to be named with the Subject Line.
  6. Items inside the folder to be named with the Subject Line at the front or the rear of the new file name.
  7. Save identically-named files and/or folders with an added marker (presumably, a (1), (2), etc.).
  8. Nothing opens by itself. I will open the documents manually at a later time for manipulation and printing.
  9. If it makes a difference to your planning, once this script functions, I would like to be able to run this script on multiple (manually-selected) files. To be clear, not an entire folder.

 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
All but #3 are fairly simple and I have macros that do all of them, mostly in separate macros, so they need to be put together.

#3 is the bug-a-boo. If the links are always in the signature, it might be easier, but that can be hit or miss. The message could be saved as plain text - but this removes all images and hyperlinks, not just the 'unwanted links'

Working with selected items:

Save as PDF

Save attachments - if this doesn't have the code to increment the files, i have it somewhere on the site.
 
Outlook version
Outlook 2013 64 bit
Email Account
Exchange Server
All but #3 are fairly simple and I have macros that do all of them, mostly in separate macros, so they need to be put together.

#3 is the bug-a-boo. If the links are always in the signature, it might be easier, but that can be hit or miss. The message could be saved as plain text - but this removes all images and hyperlinks, not just the 'unwanted links'

Working with selected items:

Save as PDF

Save attachments - if this doesn't have the code to increment the files, i have it somewhere on the site.
So excited to try these. Thank you for helping me to compile to parts.
 
Outlook version
Outlook 2013 64 bit
Email Account
Exchange Server
Follow-up -
I'm sorry. Where do I make changes within these scripts so that they align with my folders, etc.?
 
Thread starter Similar threads Forum Replies Date
N Open & Save VBAProject.Otm using VBA Code Outlook VBA and Custom Forms 1
O Cannot open or save calendar items Using Outlook 0
C How To Open Outlook Attachment in Excel, Modify some Data, then Re-Save It Using Outlook 3
C Email attachments will not open in outlook nor will they open if I save and try to open. They are sh Using Outlook 1
W Right click context menus like preview, open, save as, print etc are not working with windows 7 + Ou Using Outlook 1
M Outlook 2010 asks me "Do you want to open or save this file?" when I first run it. If I open, it con Using Outlook 3
L Cannot open PST file for first session each day Using Outlook 6
A How to open a specific link automatically with outlook 2016 Outlook VBA and Custom Forms 5
H Upon opening Outlook, make my popmail inbox open instead of outlook.com inbox Using Outlook 1
sahameed82 SharePoint calendar directly open in Outlook Using Outlook 0
N .pst archive from work will not open/import on Microsoft 365 Exchange Server Administration 0
C Outlook 2016/2019 hangs after being open for an extended period Using Outlook 4
M Where is the setting to *turn off* open calendar in a new window? Using Outlook 3
W Automatically open attachments without automatically printing them Using Outlook 0
J How to open OST file in Outlook 2019 & 2016 Using Outlook 1
C Can't Open Outlook 365 Using Outlook 0
D after delete mail, open the next one Outlook VBA and Custom Forms 0
N VBA Script to Open highlighted e-mail and Edit Message Outlook VBA and Custom Forms 5
M outlook won't open! Using Outlook 1
E Unable to open Outlook 2010 after adding new email account Using Outlook 4
M other user's mailbox won't open, forms disappeared Using Outlook 42
S SendFromAccount - Problem trying to test existing value in open email Outlook VBA and Custom Forms 2
J Open an outlook email by Subject on MS Access linked table with VBA Outlook VBA and Custom Forms 10
D Add Tetxbox at form open Outlook VBA and Custom Forms 1
U Catching ModuleSwitch events after "open in new window" Outlook VBA and Custom Forms 2
Andrew Quirl Open attachment, manipulate without add-on program? Outlook VBA and Custom Forms 5
S Reminder Dialog Open Button Using Outlook 2
A How to open a specific link automatically with outlook Outlook VBA and Custom Forms 13
S Outlook 2010 Cannot Open Attachments Using Outlook 14
N open the hyperlink in Outlook directly instead of browser Using Outlook 1
S Outlook does not open the .pst file created by the Outlook Using Outlook 5
A open Outlook with multiple windows. Using Outlook 0
K open calendar from address book Outlook VBA and Custom Forms 1
T Double clik behavior on agenda open a new meeting request Using Outlook 1
E Open olNoteItem Attachment Outlook VBA and Custom Forms 6
G Can't open .pst. Message could not access default folder (Outlook 2010 (.pst). Before that was backi Using Outlook 0
I Outlook 2010, 2013 will not open .msg or .eml files Using Outlook.com accounts in Outlook 1
Diane Poremsky Outlook VBA: Work with Open Item or Selected Item New Slipstick.com Articles 0
O Windows 10 x64 Outlook 2013 - URL does not open (anymore) Using Outlook 3
Hudas VBA find and open an email without looping thru each email in the inbox Outlook VBA and Custom Forms 1
Diane Poremsky Rules & Alerts Dialog Won't Open New Slipstick.com Articles 1
Diane Poremsky Outlook 2013: Control Panel Mail Won't Open New Slipstick.com Articles 0
Diane Poremsky Outlook Links Won't Open In Windows 10 New Slipstick.com Articles 1
C scanpst.exe will not open Using Outlook 0
K cant read email or open attachement Using Outlook 0
B ...administrator has limited the number of items you can open simultaneously Outlook VBA and Custom Forms 7
D Calendar view problems with reading pane open Using Outlook 0
Diane Poremsky Open a Webpage When a Task Reminder Fires New Slipstick.com Articles 0
B Open a folder / subfolder of a PST in single click Outlook VBA and Custom Forms 4
L Outlook 2013 won't open MS Office attachments Using Outlook 1
Similar threads


















































Top