Email Extractor from Website or URL using Excel App

Email Address Harvesting Software

To collect Email Ids from website, use this Mass Email extractor or Email harvesting software.

This is mainly used by marketting people to communicate a product advertisement to a large group of people (or personalized Email to list of addresses). We seek the help of email marketing products to extract electronic mail addresses from any of these sources – emails address list, text files, web pages or Url etc.,).

Use our product for free and buy it from our products page, once you are satisfied. Also you can learn how to build yourself a email extractor from URL. Read to know more.

Website Email Extractor – Input Format

Before proceeding with extracting Email addresses, let’s understand the basics about Email Addresses.

Every Email address corresponds to an electronic mail Box & has a Local Part and a Domain part separated by symbol “@”. (Local_Part@Domain.Part)

Related Topic: How to Fetch Email Ids from Outlook Email?

There are some restrictions on what are the allowed characters (Alphabets, Special characters, Numbers etc.,) in these sections. To know more details about limitations of these 2 sections refer to the guidelines of RFC 6531 or Wiki reference at end of this article.

Limitations of Email Extractor: At this point, we are going to assume the below points for our VBA code to work.

  1. Local & Domain part does not have SPACES, Double Quotes and any of these special characters “(),:;<>@[\]”.
  2. Excel Cell has limitation for number of characters. If the text content has very huge content, modify the code to read the content from a text file and parse the email Ids.

How to Extract Email address from Website or URL?

The Excel Macro VBA code in this page scans the text content, character by character and extract email Ids from website (local & domain parts) in that page.

  • If the content is in text file, copy paste the text file to Excel sheet 1, cell A2 and execute this code.
  • If the content is in webpage, get the HTML source of the webpage and paste in the Excel in same location as above.

Once, the content is copied to Excel sheet (Excel macro for beginners), press Alt+F11 to go to VB Editor. Then cope paste the below code and Execute the code by pressing F5.

Note: By Combining this code and the code from this page, you can make code to extract emails from websites all by yourself.

Private Sub Email_Extractor_From_Website()
    Dim oWebData As Object, sPageHTML  As String, sWebURL As String
 
    'Change the URL before executing the code
    sWebURL = "http://officetricks.com"
 
    'Extract data from website to Excel using VBA
    Set oWebData = CreateObject("MSXML2.ServerXMLHTTP")
    oWebData.Open "GET", sWebURL, False
    oWebData.send
    sPageHTML = oWebData.responseText
 
    'Get webpage data into Excel
    Extract_Email_Address_From_Text sPageHTML
End Sub

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'          Visit our website for more Tips and Tricks
'                ---- Officetricks.com ----
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub Extract_Email_Address_From_Text(Optional Text_Content As String)
    Dlim_List = " ""(),:;<>@[\]"

    'Get Text Content and assign to a Variable
    If Text_Content = "" Then
        Text_Content = ThisWorkbook.Sheets(1).Cells(2, 1)
    End If
    Web_Page_Text1 = Text_Content
    If Web_Page_Text1 = "" Then
        MsgBox "Error: No Input Provided - Provide Input"
        Exit Sub
    End If
    
    'Scan each word in Text and Extract Email Addresses
    ORow = 2
    While (Web_Page_Text1 <> "")
    
        'Locate position of symbol "@"
        First_@ = VBA.InStr(1, Web_Page_Text1, "@", vbTextCompare)
        
        'If there is no occurance of "@" then terminate process
        If First_@ = 0 Then GoTo End_sub:
        
        'Seperate
        Web_Page_Text2 = VBA.Mid(Web_Page_Text1, 1, First_@ - 1)
        Web_Page_Text3 = VBA.Mid(Web_Page_Text1, First_@ + 1)
        Dlim_Pos_Max = 99999
        Dlim_Pos_Min = 0
        
        For i = 1 To VBA.Len(Dlim_List)
            Dlim_2_Compare = VBA.Mid(Dlim_List, i, 1)
                        
            Dlim_Pos = VBA.InStrRev(Web_Page_Text2, Dlim_2_Compare, -1, vbTextCompare)
            If (Dlim_Pos > Dlim_Pos_Min) And (Dlim_Pos > 0) Then Dlim_Pos_Min = Dlim_Pos

            Dlim_Pos = VBA.InStr(1, Web_Page_Text3, Dlim_2_Compare, vbTextCompare)
            If (Dlim_Pos < Dlim_Pos_Max) And (Dlim_Pos > 0) Then Dlim_Pos_Max = Dlim_Pos
        Next i
        If Dlim_Pos_Max = 0 Then GoTo End_sub:
        
        'get Email list to Text Variable
        Email_Domain_Part = VBA.Mid(Web_Page_Text3, 1, Dlim_Pos_Max - 1)
        Email_Local_Part = VBA.Mid(Web_Page_Text2, Dlim_Pos_Min + 1, VBA.Len(Web_Page_Text2) - Dlim_Pos_Min)
        Mail_Address = Email_Local_Part & "@" & Email_Domain_Part
        
        'Scan through remaining content
        ORow = ORow + 1
        ThisWorkbook.Sheets(1).Cells(ORow, 2).Select
        ThisWorkbook.Sheets(1).Cells(ORow, 2) = Mail_Address
        Web_Page_Text1 = VBA.Mid(Web_Page_Text1, Dlim_Pos_Max + First_@ + 1)
    Wend
    
End_sub:
    MsgBox " Process Completed"
End Sub

Email Extractor Software Download

In recent Google and Web technology we use these fancy words like Spider, Crawler often. Such software sweep through complete code or content and extract the information that they are meant to harvest.

Thus this Excel VBA Code is an Email Spider which provides email marketing help. Huge number of Emails can be extracted with this automation process in just one click, which will save lot of manual effort.

Download Free Email Extractor from Website to Excel Downloaded 1,165 Times

Note: Refer to the limitations explained in Format of Email Address & Wiki reference, before using this template. If the code is not working at some point, it might be due to the limitation explained in these sections.

Wiki Reference: Email addresses format and limitations

Leave a Reply