At times, you may want to copy all the embedded URLs, namely webpage links, in an email to a new email. In this case, you can use the approach introduced in this post.
If you receive an email which is embedded with a great number of website links involving an important project, you may want to forward these URLs to someone else. It’s so troublesome that you copy the URLs to a new email manually. Here is a quick method to realize it with VBA. To run VBA code in Outlook, you can refer to the article – “How to Run VBA Code in Your Outlook”.
Copy All Embedded URLs from One Email to Another
- At the very beginning, launch your Outlook program.
- Then, access Outlook VBA editor window.
- Next, copy and paste the following VBA code into a project or module.
Sub CopyAllHyperlinksFromOneMailToAnother() Dim objMail, objNewMail As Outlook.MailItem Dim objRegExp As RegExp Dim objMatchCollection As MatchCollection Dim objMatch As Match Dim i As Long Dim strURL, strURLs As String 'Get the source mail Select Case Outlook.Application.ActiveWindow.Class Case olInspector Set objMail = ActiveInspector.CurrentItem Case olExplorer Set objMail = ActiveExplorer.Selection.Item(1) End Select 'Get URLs using regular expression Set objRegExp = New RegExp With objRegExp .Pattern = "(https?[:]//([0-9a-z=\?:/\.&-^!#$;_])*)" .Global = True .IgnoreCase = True End With If objRegExp.test(objMail.Body) Then Set objMatchCollection = objRegExp.Execute(objMail.Body) i = 0 For Each objMatch In objMatchCollection strURL = objMatch.SubMatches(0) strURL = Left(strURL, Len(strURL) - 1) i = i + 1 strURLs = strURLs & i & ". " & strURL & vbCr & vbCr Next End If 'Input the URL list into a new email If Trim(strURLs) <> "" Then Set objNewMail = Outlook.Application.CreateItem(olMailItem) With objNewMail .Body = strURLs .Display End With End If End Sub
- After that, add this macro to Quick Access Toolbar.
- Finally, you can try this macro.
- First off, select or open the source email.
- Then, click on the macro button in Quick Access Toolbar.
- Immediately, when the macro finishes, you will get a new email, in which there is a list of URLs extracted from the source email.
- It will look like the following screenshot:
Keep Calm In Case of Outlook Corruptions
Many users will become considerably worried as encountering Outlook damage in that they are afraid that their valuable Outlook data will be unrecoverable. As a matter of fact, you can take 3 means to restore your data. At first, you can check if there is an updated data backup. If not, proceed to rescue your damaged Outlook file via Scanpst.exe. Assuming that it fails as well, you can attempt recovery with a powerful external tool, such as DataNumen Outlook Repair.
Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including mdf repair and outlook repair software products. For more information visit www.datanumen.com