?
Solved

Outlook 2013 Exporting Email Addresses

Posted on 2014-12-09
6
Medium Priority
?
132 Views
Last Modified: 2014-12-13
I have a user connected to Exchange 2013 using Outlook 2013.  He has a folder in Outlook called ABC Emails and he has stored a bunch of emails in there.  He has requested to export or harvest ALL of the email address attached to the emails within that particular folder, OR all email addresses attached to ALL emails within the inbox.  His goal is to gather as may email addresses as possible to export, even if they are not contacts within Outlook.

Can this be done?
0
Comment
Question by:BSModlin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 4

Expert Comment

by:akalyan911
ID: 40489222
No.. As far i have knowledge..

he can't extract the all contacts of emails at one time..
0
 
LVL 14

Assisted Solution

by:Alexei Kuznetsov (Outlook MVP)
Alexei Kuznetsov (Outlook MVP) earned 1000 total points
ID: 40490725
This can't be done out of the box. This can be done with either VBA script or third-party utility however. VBA script will be quite complex in this case. This is why I want to recommend the free Save Email Addresses utility. It can extract all email addresses to the specified text file. There are also utilities that can extract addresses to contacts of groups of contacts .

DISCLAIMER: I'm one of the developers of mentioned tools. So feel free to ask any further questions.
0
 
LVL 26

Accepted Solution

by:
Nick67 earned 1000 total points
ID: 40492907
It ain't rocket science
This code will grab all the sender addresses from a user-chosen folder if pasted into an Excel code module and run
It puts them all in column A of Sheet 2
it opens Outlook properly and then Raids

Option Explicit
Public wasOpen As Boolean

Function StartApp(ByVal appName) As Object
On Error GoTo ErrorHandler
Dim oApp As Object

wasOpen = True
Set oApp = GetObject(, appName)    'Error here - Run-time error '429':
Set StartApp = oApp

Exit Function

ErrorHandler:
If Err.Number = 429 Then
    'App is not running; open app with CreateObject
    Set oApp = CreateObject(appName)
    wasOpen = False
    Resume Next
Else
    MsgBox Err.Number & " " & Err.Description
End If
End Function

Public Sub Raid()
On Error Resume Next
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
Dim objOutlookExplorers As Outlook.Explorers
Dim myitem As Object
Dim ns As Outlook.Namespace
Dim Folder As Outlook.MAPIFolder

Set objOutlook = StartApp("Outlook.Application")
Set ns = objOutlook.GetNamespace("MAPI")
Set Folder = ns.PickFolder
Set objOutlookExplorers = objOutlook.Explorers

If wasOpen = False Then
    objOutlookExplorers.Add Folder
    Folder.Display
    'done opening
End If

Dim x As Long
x = 1
For Each myitem In Folder.Items
    With myitem
        If Len(.SenderEmailAddress) > 0 Then
            Sheets(2).Cells(x, 1).Value = .SenderEmailAddress
            Sheets(2).Cells(x, 2).Value = .CC
            Sheets(2).Cells(x, 3).Value = .BCC
        End If
    End With
    x = x + 1
skip:
Next myitem
    
End Sub

Open in new window

0
Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

 
LVL 26

Expert Comment

by:Nick67
ID: 40492924
But, since CC and BCC return names, not addresses, you'll need this:
Option Explicit
Public wasOpen As Boolean

Function StartApp(ByVal appName) As Object
On Error GoTo ErrorHandler
Dim oApp As Object

wasOpen = True
Set oApp = GetObject(, appName)    'Error here - Run-time error '429':
Set StartApp = oApp

Exit Function

ErrorHandler:
If Err.Number = 429 Then
    'App is not running; open app with CreateObject
    Set oApp = CreateObject(appName)
    wasOpen = False
    Resume Next
Else
    MsgBox Err.Number & " " & Err.Description
End If
End Function

Public Sub Raid()
On Error Resume Next
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
Dim objOutlookExplorers As Outlook.Explorers
Dim myitem As Object
Dim ns As Outlook.Namespace
Dim Folder As Outlook.MAPIFolder

Set objOutlook = StartApp("Outlook.Application")
Set ns = objOutlook.GetNamespace("MAPI")
'Set Folder = ns.GetDefaultFolder(olFolderInbox)
Set Folder = ns.PickFolder
Set objOutlookExplorers = objOutlook.Explorers

If wasOpen = False Then
    objOutlookExplorers.Add Folder
    Folder.Display
    'done opening
End If

Dim x As Long
Dim y As Long
x = 1
For Each myitem In Folder.Items
    y = 2
    With myitem
        If Len(.SenderEmailAddress) > 0 Then
            Sheets(2).Cells(x, 1).Value = .SenderEmailAddress
            For Each objOutlookRecip In .Recipients
                Sheets(2).Cells(x, y).Value = objOutlookRecip.Address
                y = y + 1
            Next objOutlookRecip
        End If
    End With
    x = x + 1
skip:
Next myitem
    
End Sub

Open in new window


Senders in A, CC and BCC addresses to the right of that.

When it publishes, an explanation of how to properly open Outlook for automation will be here
http://www.experts-exchange.com/Programming/Microsoft_Development/A_17466-Properly-open-Outlook-as-an-Application-object-in-VBA.html
0
 
LVL 14

Expert Comment

by:Alexei Kuznetsov (Outlook MVP)
ID: 40493478
@Nick67, this will not extract emails from message texts (you need much more code to get the emails from texts). Moreover, Address property is not necessary of SMTP type. Additional steps may be needed to get the correct SMTP address depending on Outlook version.
0
 
LVL 26

Expert Comment

by:Nick67
ID: 40494186
this will not extract emails from message texts (you need much more code to get the emails from texts).
I don't know that my reading of the question implies that the body is to be parsed for vaiid mailto addresses.
Even so, 20 or so lines of code with RegEx parsing for *@*.* with either leading or trailing spaces or semi-colons ought to get that done, if truly desired.

Address property is not necessary of SMTP type.
But those that aren't will be primarily Active Directory addresses -- which will not be required anyway, as Outlook will already have them in a global address list.

Additional steps may be needed to get the correct SMTP address depending on Outlook version.
I am working with O2003, which is already out of support, and the code works fine.  I doubt that support for earlier versions than that will be required. (Outlook 2013 is referenced in the question title)
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will help to fix the below errors for MS Exchange Server 2013 I. Certificate error "name on the security certificate is invalid or does not match the name of the site" II. Out of Office not working III. Make Internal URLs and Externa…
Outlook for dependable use in a very small business   This article is about using the Outlook application (part of Microsoft Office) in a very small business, or for homeowners where dependability and reliability are critical requirements. This …
In this video we show how to create an email address policy in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.:  First we need to log into the Exchange Admin Center. Navigate to the Mail Flow…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Suggested Courses

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question