harvest email addresses from outlook

kgkev

Well-known Member
Joined
Jun 24, 2008
Messages
1,291
Office Version
  1. 365
Platform
  1. Windows
I have modified some code to harvest email address from my outlook

It works perfectly for getting email names and address for incoming email addresses

Code:
Sub GetFromInbox()
Application.ScreenUpdating = False

    Dim olApp As Outlook.Application
    Dim olNs As NameSpace
    Dim Fldr As MAPIFolder
    Dim olMail As MailItem
    Dim i As Integer
    Dim x As Integer
    Dim y As Integer
    Dim internalcount As Integer
    

    Set olApp = New Outlook.Application
    Set olNs = olApp.GetNamespace("MAPI")
    Set Fldr = olNs.GetDefaultFolder(olFolderInbox)
    Set Fldr = Fldr.Folders("2011").Folders("inbox")
    UserForm1.Show False
    
    i = 1
    x = 1
    
    Sheets("New").Cells.ClearContents
    y = Fldr.Items.Count
    
    For Each olMail In Fldr.Items
        UserForm1.TextBox1.Value = x & "  //  " & y
        UserForm1.Repaint
        
            Sheets("New").Cells(i, 1).Value = olMail.SenderName
            Sheets("New").Cells(i, 2).Value = olMail.SenderEmailAddress
            i = i + 1
        
            x = x + 1
        On Error Resume Next
    Next olMail
    UserForm1.Hide
    
    Set Fldr = Nothing
    Set olNs = Nothing
    Set olApp = Nothing

End Sub

However I now want to gather the email addresses of all the people I have sent messages to. The only mailitem property I can find is .to

This works for some but others just gives the persons name.

Any ideas how I can get the full email address from the mailitem property?
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

Forum statistics

Threads
1,224,544
Messages
6,179,430
Members
452,915
Latest member
hannnahheileen

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top