Jump to content

Email address scraper

Go to solution Solved by svegori1950,

I edited it please check

If you have all your mails in Microsoft Office Outlook, VBA script can be used to extract them as shown in here.

Then you could save them as contacts as shown in here.

Also You would need to loop through all mails in sent folder, which can be done as shown in here.

At the end your script would be something like:

Sub GetSMTPAddressForRecipients(mail As Outlook.MailItem) 
    Dim recips As Outlook.Recipients 
    Dim recip As Outlook.Recipient 
    Dim pa As Outlook.PropertyAccessor 
    Const PR_SMTP_ADDRESS As String = _ 
        "http://schemas.microsoft.com/mapi/proptag/0x39FE001E" 
    Set recips = mail.Recipients 
    For Each recip In recips 
        Set pa = recip.PropertyAccessor 
        Dim contactItem  As Outlook.contactItem
        Set contactItem = Application.CreateItem(olContactItem)
        contactItem.FullName = recip.name
        contactItem.Email1Address = pa.GetProperty(PR_SMTP_ADDRESS)
    Next 
End Sub

Dim objNS As Outlook.NameSpace: Set objNS = GetNamespace("MAPI")
Dim olFolder As Outlook.MAPIFolder
Set olFolder = objNS.GetDefaultFolder(olFolderInbox)
Dim Item As Object

For Each Item In olFolder.Items
    If TypeOf Item Is Outlook.MailItem Then 
      GetSMTPAddressForRecipients(Item)
    End If
Next

 

 

 

(Disclaimer: I'm not very familiar with VBA so it is very likely that this won't work)

Link to comment
https://linustechtips.com/topic/1041002-email-address-scraper/#findComment-12362777
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×