+ Reply to Thread
Results 1 to 15 of 15

Get Email from Outlook GAL to Namelist in Excel

Hybrid View

  1. #1
    Registered User
    Join Date
    03-11-2014
    Location
    Hanover, Germany
    MS-Off Ver
    Excel 2003
    Posts
    8

    Exclamation Get Email from Outlook GAL to Namelist in Excel

    Hello everybody,

    Í have a Namelist in Excel (Sheet1: row: A1) and I need the Email-Address for this names
    from Outlook GAL. I found an Macro that works on Excel 2007, but I need one which is
    working on Excel 2003.

    Please can You help me?


    OnBak



    Private Const olExchangeGlobalAddressList As Integer = 0
    Private Const olExchangeUserAddressEntry As Integer = 0
    Private Const olExchangeRemoteUserAddressEntry As Integer = 5

    Public Sub VergleichExcelMitGAL()
    Dim oOutlook As Object
    Dim oAddressList As Object
    Dim oAddressEntry As Object
    Dim oExchangeUser As Object
    Dim Länge As Integer


    Range("A1").Select
    Set oOutlook = CreateObject("Outlook.Application")


    For Each oAddressList In oOutlook.Session.AddressLists

    If oAddressList.AddressListType = olExchangeGlobalAddressList Then

    For Each oAddressEntry In oAddressList.AddressEntries

    If oAddressEntry.AddressEntryUserType = olExchangeUserAddressEntry _
    Or oAddressEntry.AddressEntryUserType = olExchangeRemoteUserAddressEntry Then

    Set oExchangeUser = oAddressEntry.GetExchangeUser


    Range("A1").Select
    While Selection <> ""
    Länge = Len(ActiveCell)
    If ActiveCell = Left(oExchangeUser.Alias, Länge) Then
    Sheets(2).Select
    Selection = oExchangeUser.Name
    ActiveCell.Offset(0, 1) = oExchangeUser.Alias
    ActiveCell.Offset(0, 2) = oExchangeUser.Email
    ActiveCell.Offset(1, 0).Select
    Sheets(1).Select
    End If
    ActiveCell.Offset(1, 0).Select
    Wend
    End If
    Next
    End If
    Next

    Set oExchangeUser = Nothing
    Set oAddressEntry = Nothing
    Set oAddressList = Nothing
    Set oOutlook = Nothing
    End Sub

  2. #2
    Valued Forum Contributor adyteo's Avatar
    Join Date
    01-10-2013
    Location
    Calgary
    MS-Off Ver
    Excel 2010
    Posts
    540

    Re: Get Email from Outlook GAL to Namelist in Excel

    try this code:
    http://www.excelforum.com/outlook-fo...ml#post3567396

    I couldn't test it for 2003.
    Click on the star if you think I helped you

  3. #3
    Registered User
    Join Date
    03-11-2014
    Location
    Hanover, Germany
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Get Email from Outlook GAL to Namelist in Excel

    Thank you adyteo, but it doesn't work..
    I have a namelist and I need the Email-Address for those names. In this list are more than 1000 names :/
    I'm new @vba and i have problems to write my own macro

  4. #4
    Valued Forum Contributor adyteo's Avatar
    Join Date
    01-10-2013
    Location
    Calgary
    MS-Off Ver
    Excel 2010
    Posts
    540

    Re: Get Email from Outlook GAL to Namelist in Excel

    onbak
    If you put the list of names in rows, then you can select all these cells (A2:Axxx) and then run the macro. This is what I actually do.
    What does not work for you? Any error message?

  5. #5
    Registered User
    Join Date
    03-11-2014
    Location
    Hanover, Germany
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Get Email from Outlook GAL to Namelist in Excel

    I get this error message (Dim oExUser As Outlook.ExchangeUser):

    compile error:
    user-defined type not defined

  6. #6
    Valued Forum Contributor adyteo's Avatar
    Join Date
    01-10-2013
    Location
    Calgary
    MS-Off Ver
    Excel 2010
    Posts
    540

    Re: Get Email from Outlook GAL to Namelist in Excel

    Quote Originally Posted by OnBak View Post
    I get this error message (Dim oExUser As Outlook.ExchangeUser):

    compile error:
    user-defined type not defined
    What you need to do is:
    Press Alt-F11
    Click Tools --> References

    I believe you are missing the reference "Microsoft Outlook 14.0 Object Library". What you need to do is to find "Microsoft Outlook xx.0 Object Library" where xx could be 10, 11, 12, 13,14 based on the Microsoft Office you have. Once you select that Library, you should be able to run the macro.

  7. #7
    Registered User
    Join Date
    03-11-2014
    Location
    Hanover, Germany
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Get Email from Outlook GAL to Namelist in Excel

    It's already selected. I use "Microsoft Outlook 11.0 Object Library".
    Can I upload my excel file?

  8. #8
    Valued Forum Contributor adyteo's Avatar
    Join Date
    01-10-2013
    Location
    Calgary
    MS-Off Ver
    Excel 2010
    Posts
    540

    Re: Get Email from Outlook GAL to Namelist in Excel

    Yes, let's try it this way

  9. #9
    Registered User
    Join Date
    03-11-2014
    Location
    Hanover, Germany
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Get Email from Outlook GAL to Namelist in Excel

    test.xls

    i dont know, why this isnt working..

  10. #10
    Valued Forum Contributor adyteo's Avatar
    Join Date
    01-10-2013
    Location
    Calgary
    MS-Off Ver
    Excel 2010
    Posts
    540

    Re: Get Email from Outlook GAL to Namelist in Excel

    Outlook.ExchangeUser was added to Outlook 2007. It does not exist in 2003 version.
    http://msdn.microsoft.com/en-us/libr...ice.15%29.aspx

  11. #11
    Registered User
    Join Date
    03-11-2014
    Location
    Hanover, Germany
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Get Email from Outlook GAL to Namelist in Excel

    Can I use another code for "Outlook.ExchangeUser" ?

  12. #12
    Valued Forum Contributor adyteo's Avatar
    Join Date
    01-10-2013
    Location
    Calgary
    MS-Off Ver
    Excel 2010
    Posts
    540

    Re: Get Email from Outlook GAL to Namelist in Excel

    I took your file and for me it worked. Maybe because automatically Microsoft Outlook 14.0 Object Library was loaded. It could be that Microsoft Outlook 11.0 Object Library has different members. I am sorry.

  13. #13
    Registered User
    Join Date
    03-11-2014
    Location
    Hanover, Germany
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Get Email from Outlook GAL to Namelist in Excel

    Ah ok. I'm currently at work and they are using office 2003.

    I'll try ur code later at home, when it works. i will tell you

    Thank you.

  14. #14
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Get Email from Outlook GAL to Namelist in Excel

    Wouldn't it be easier to read this data from Active Directory?

  15. #15
    Registered User
    Join Date
    03-11-2014
    Location
    Hanover, Germany
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Get Email from Outlook GAL to Namelist in Excel

    I think this code below is an good alternative, for extracting Email from GAL:

    'Send Mail
    'OnBak 12.03.2014


    Private Sub CommandButton1_Click()
    Dim Nachricht As Object, OutlookApplication As Object
    Set OutlookApplication = CreateObject("Outlook.Application")
    Dim Anhang As String
    Dim Adress As String
    Dim sAddress As String, sSubject As String, sBody As String
    Dim Name As String

    Anhang = ThisWorkbook.FullName
    Set Nachricht = OutlookApplication.CreateItem(0)

    ' Wo Wert = @, wird übernommen und ";" eingefügt
    For Each cell In Columns("A").Cells.SpecialCells(xlCellTypeVisible)
    If cell.Value = cell.Value Then
    sAddress = sAddress & ";" & cell.Value
    End If
    Next

    'Eingabe Betreff und Text
    sSubject = InputBox("Please enter a subject", "Enter subject")
    sBody = InputBox("Please enter your text here:", "Enter text")

    'Übergabe
    With Nachricht
    .To = sAddress
    .Subject = sSubject
    .Attachments.Add "D:\LocalHome\bakis\My Documents\2. VBA practice\empty document.txt" 'Anhang
    .Body = sBody
    .Display
    .Send
    End With

    Set OutlookApplication = Nothing
    Set Nachricht = Nothing
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. vba pull data from outlook body of email through email or subject of mail into excel
    By breadwinner in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-01-2014, 04:37 AM
  2. export outlook 2007 email into excel with subject and body of email
    By akulka58 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-25-2013, 02:37 PM
  3. How to parse data in Outlook email using HTML version of email back to excel
    By bnasty in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 10-31-2012, 02:54 PM
  4. Replies: 2
    Last Post: 08-01-2012, 02:47 PM
  5. Email using Excel VBA and Keeping Outlook Signature on the Email
    By Shama in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-13-2009, 07:39 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1