Outlook - distribution list member details












0














I am trying to get details for users in a distribution list (containing ~200 people).



When I create a new email, add this DL as the only recipient and run the macro below, it returns ~15 first results, then "Outlook is trying to retrieve data from the Microsoft Exchange server" tray message appears and after some time I get "The operation failed" error.



If I continue the code execution the next ~15 values are returned and this issue reappears. Seams like there is some Exchange anti-spam limit.



Sub GetDetails(olMail As MailItem)

Dim i As Integer, j As Integer
For i = 1 To olMail.Recipients.Count ' count = 1
If olMail.Recipients.Item(i).AddressEntry.GetExchangeUser Is Nothing Then
For j = 1 To olMail.Recipients.Item(i).AddressEntry.Members.Count ' count ~= 200
Debug.Print olMail.Recipients.Item(i).AddressEntry.Members.Item(j).GetExchangeUser.FirstName
Next j
End If
Next i
End Sub


But if I expand the distribution list (using the '+' icon) and run slightly modified code, results for all users are returned with no issues (taking a few seconds only).



Sub GetDetails(olMail As MailItem)

Dim i As Integer
For i = 1 To olMail.Recipients.Count ' count ~= 200
If Not olMail.Recipients.Item(i).AddressEntry.GetExchangeUser Is Nothing Then
Debug.Print olMail.Recipients.Item(i).AddressEntry.GetExchangeUser.FirstName
End If
Next i
End Sub


Any ideas?










share|improve this question
























  • is there anyone on the distro list that isn't an ExchangeUser? Your second snippet accounts for that, but it looks like the first one does not (it handles the Recipients.Item(1) but not the individual recipients'). (this is just a shot in the dark, and I don't have any other ideas)
    – David Zemens
    Apr 14 '17 at 20:31










  • All are exchange users. The problem is I don't know how to iterate through them as through individual recipients.
    – Michał Malus
    Apr 15 '17 at 18:43










  • one thought would be to add a call to the WinAPI Sleep function for 100 or 200 ms. the error you're getting looks like a conflict/timeout sort of thing that you might avoid with a very small pause at each iteration.
    – David Zemens
    Apr 15 '17 at 18:47










  • Tried even with 1 - 1.5s. Issue still occurs. "Expanded" list (2nd approach) returns data for all emails in ~3 seconds..
    – Michał Malus
    Apr 17 '17 at 12:57






  • 1




    Seems like the first approach queries the Exchange Server while the second queries all the data locally.
    – Michał Malus
    Apr 17 '17 at 13:04
















0














I am trying to get details for users in a distribution list (containing ~200 people).



When I create a new email, add this DL as the only recipient and run the macro below, it returns ~15 first results, then "Outlook is trying to retrieve data from the Microsoft Exchange server" tray message appears and after some time I get "The operation failed" error.



If I continue the code execution the next ~15 values are returned and this issue reappears. Seams like there is some Exchange anti-spam limit.



Sub GetDetails(olMail As MailItem)

Dim i As Integer, j As Integer
For i = 1 To olMail.Recipients.Count ' count = 1
If olMail.Recipients.Item(i).AddressEntry.GetExchangeUser Is Nothing Then
For j = 1 To olMail.Recipients.Item(i).AddressEntry.Members.Count ' count ~= 200
Debug.Print olMail.Recipients.Item(i).AddressEntry.Members.Item(j).GetExchangeUser.FirstName
Next j
End If
Next i
End Sub


But if I expand the distribution list (using the '+' icon) and run slightly modified code, results for all users are returned with no issues (taking a few seconds only).



Sub GetDetails(olMail As MailItem)

Dim i As Integer
For i = 1 To olMail.Recipients.Count ' count ~= 200
If Not olMail.Recipients.Item(i).AddressEntry.GetExchangeUser Is Nothing Then
Debug.Print olMail.Recipients.Item(i).AddressEntry.GetExchangeUser.FirstName
End If
Next i
End Sub


Any ideas?










share|improve this question
























  • is there anyone on the distro list that isn't an ExchangeUser? Your second snippet accounts for that, but it looks like the first one does not (it handles the Recipients.Item(1) but not the individual recipients'). (this is just a shot in the dark, and I don't have any other ideas)
    – David Zemens
    Apr 14 '17 at 20:31










  • All are exchange users. The problem is I don't know how to iterate through them as through individual recipients.
    – Michał Malus
    Apr 15 '17 at 18:43










  • one thought would be to add a call to the WinAPI Sleep function for 100 or 200 ms. the error you're getting looks like a conflict/timeout sort of thing that you might avoid with a very small pause at each iteration.
    – David Zemens
    Apr 15 '17 at 18:47










  • Tried even with 1 - 1.5s. Issue still occurs. "Expanded" list (2nd approach) returns data for all emails in ~3 seconds..
    – Michał Malus
    Apr 17 '17 at 12:57






  • 1




    Seems like the first approach queries the Exchange Server while the second queries all the data locally.
    – Michał Malus
    Apr 17 '17 at 13:04














0












0








0







I am trying to get details for users in a distribution list (containing ~200 people).



When I create a new email, add this DL as the only recipient and run the macro below, it returns ~15 first results, then "Outlook is trying to retrieve data from the Microsoft Exchange server" tray message appears and after some time I get "The operation failed" error.



If I continue the code execution the next ~15 values are returned and this issue reappears. Seams like there is some Exchange anti-spam limit.



Sub GetDetails(olMail As MailItem)

Dim i As Integer, j As Integer
For i = 1 To olMail.Recipients.Count ' count = 1
If olMail.Recipients.Item(i).AddressEntry.GetExchangeUser Is Nothing Then
For j = 1 To olMail.Recipients.Item(i).AddressEntry.Members.Count ' count ~= 200
Debug.Print olMail.Recipients.Item(i).AddressEntry.Members.Item(j).GetExchangeUser.FirstName
Next j
End If
Next i
End Sub


But if I expand the distribution list (using the '+' icon) and run slightly modified code, results for all users are returned with no issues (taking a few seconds only).



Sub GetDetails(olMail As MailItem)

Dim i As Integer
For i = 1 To olMail.Recipients.Count ' count ~= 200
If Not olMail.Recipients.Item(i).AddressEntry.GetExchangeUser Is Nothing Then
Debug.Print olMail.Recipients.Item(i).AddressEntry.GetExchangeUser.FirstName
End If
Next i
End Sub


Any ideas?










share|improve this question















I am trying to get details for users in a distribution list (containing ~200 people).



When I create a new email, add this DL as the only recipient and run the macro below, it returns ~15 first results, then "Outlook is trying to retrieve data from the Microsoft Exchange server" tray message appears and after some time I get "The operation failed" error.



If I continue the code execution the next ~15 values are returned and this issue reappears. Seams like there is some Exchange anti-spam limit.



Sub GetDetails(olMail As MailItem)

Dim i As Integer, j As Integer
For i = 1 To olMail.Recipients.Count ' count = 1
If olMail.Recipients.Item(i).AddressEntry.GetExchangeUser Is Nothing Then
For j = 1 To olMail.Recipients.Item(i).AddressEntry.Members.Count ' count ~= 200
Debug.Print olMail.Recipients.Item(i).AddressEntry.Members.Item(j).GetExchangeUser.FirstName
Next j
End If
Next i
End Sub


But if I expand the distribution list (using the '+' icon) and run slightly modified code, results for all users are returned with no issues (taking a few seconds only).



Sub GetDetails(olMail As MailItem)

Dim i As Integer
For i = 1 To olMail.Recipients.Count ' count ~= 200
If Not olMail.Recipients.Item(i).AddressEntry.GetExchangeUser Is Nothing Then
Debug.Print olMail.Recipients.Item(i).AddressEntry.GetExchangeUser.FirstName
End If
Next i
End Sub


Any ideas?







vba outlook exchange-server outlook-vba






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 15 '17 at 1:27









0m3r

7,60392353




7,60392353










asked Apr 14 '17 at 20:20









Michał Malus

216




216












  • is there anyone on the distro list that isn't an ExchangeUser? Your second snippet accounts for that, but it looks like the first one does not (it handles the Recipients.Item(1) but not the individual recipients'). (this is just a shot in the dark, and I don't have any other ideas)
    – David Zemens
    Apr 14 '17 at 20:31










  • All are exchange users. The problem is I don't know how to iterate through them as through individual recipients.
    – Michał Malus
    Apr 15 '17 at 18:43










  • one thought would be to add a call to the WinAPI Sleep function for 100 or 200 ms. the error you're getting looks like a conflict/timeout sort of thing that you might avoid with a very small pause at each iteration.
    – David Zemens
    Apr 15 '17 at 18:47










  • Tried even with 1 - 1.5s. Issue still occurs. "Expanded" list (2nd approach) returns data for all emails in ~3 seconds..
    – Michał Malus
    Apr 17 '17 at 12:57






  • 1




    Seems like the first approach queries the Exchange Server while the second queries all the data locally.
    – Michał Malus
    Apr 17 '17 at 13:04


















  • is there anyone on the distro list that isn't an ExchangeUser? Your second snippet accounts for that, but it looks like the first one does not (it handles the Recipients.Item(1) but not the individual recipients'). (this is just a shot in the dark, and I don't have any other ideas)
    – David Zemens
    Apr 14 '17 at 20:31










  • All are exchange users. The problem is I don't know how to iterate through them as through individual recipients.
    – Michał Malus
    Apr 15 '17 at 18:43










  • one thought would be to add a call to the WinAPI Sleep function for 100 or 200 ms. the error you're getting looks like a conflict/timeout sort of thing that you might avoid with a very small pause at each iteration.
    – David Zemens
    Apr 15 '17 at 18:47










  • Tried even with 1 - 1.5s. Issue still occurs. "Expanded" list (2nd approach) returns data for all emails in ~3 seconds..
    – Michał Malus
    Apr 17 '17 at 12:57






  • 1




    Seems like the first approach queries the Exchange Server while the second queries all the data locally.
    – Michał Malus
    Apr 17 '17 at 13:04
















is there anyone on the distro list that isn't an ExchangeUser? Your second snippet accounts for that, but it looks like the first one does not (it handles the Recipients.Item(1) but not the individual recipients'). (this is just a shot in the dark, and I don't have any other ideas)
– David Zemens
Apr 14 '17 at 20:31




is there anyone on the distro list that isn't an ExchangeUser? Your second snippet accounts for that, but it looks like the first one does not (it handles the Recipients.Item(1) but not the individual recipients'). (this is just a shot in the dark, and I don't have any other ideas)
– David Zemens
Apr 14 '17 at 20:31












All are exchange users. The problem is I don't know how to iterate through them as through individual recipients.
– Michał Malus
Apr 15 '17 at 18:43




All are exchange users. The problem is I don't know how to iterate through them as through individual recipients.
– Michał Malus
Apr 15 '17 at 18:43












one thought would be to add a call to the WinAPI Sleep function for 100 or 200 ms. the error you're getting looks like a conflict/timeout sort of thing that you might avoid with a very small pause at each iteration.
– David Zemens
Apr 15 '17 at 18:47




one thought would be to add a call to the WinAPI Sleep function for 100 or 200 ms. the error you're getting looks like a conflict/timeout sort of thing that you might avoid with a very small pause at each iteration.
– David Zemens
Apr 15 '17 at 18:47












Tried even with 1 - 1.5s. Issue still occurs. "Expanded" list (2nd approach) returns data for all emails in ~3 seconds..
– Michał Malus
Apr 17 '17 at 12:57




Tried even with 1 - 1.5s. Issue still occurs. "Expanded" list (2nd approach) returns data for all emails in ~3 seconds..
– Michał Malus
Apr 17 '17 at 12:57




1




1




Seems like the first approach queries the Exchange Server while the second queries all the data locally.
– Michał Malus
Apr 17 '17 at 13:04




Seems like the first approach queries the Exchange Server while the second queries all the data locally.
– Michał Malus
Apr 17 '17 at 13:04












2 Answers
2






active

oldest

votes


















1














You need to release Outlook COM objects instantly in the code. This is particularly important if your add-in attempts to enumerate more than 256 Outlook items in a collection that is stored on a Microsoft Exchange Server. If you do not release these objects in a timely manner, you can reach the limit imposed by Exchange on the maximum number of items opened at any one time. When you are done, just set a variable to Nothing to release the reference to the object.






share|improve this answer





















  • Issue occurs after few iterations (~10). Releasing objects Dim o Set o = olMail.Recipients.Item(i).AddressEntry.Members.Item(j) Debug.Print o.GetExchangeUser.FirstName Set o = Nothing doesn't help.
    – Michał Malus
    Apr 17 '17 at 12:55








  • 1




    I see a lot of dots in the single line of code. So, I'd suggest breaking the chain of property and methods calls and declare them on separate line (each property or method on a single line of code). Thus you will be able to release them in a timely manner.
    – Eugene Astafiev
    Apr 17 '17 at 14:00










  • It may be the Members object that needs releasing, not the Item object...
    – David Zemens
    Apr 17 '17 at 14:42










  • I agree but that doesn't resolve the issue. It seems that the AddressEntry is resolved locally and AddressEntry.Members on the server hitting some limits for big DLs.
    – Michał Malus
    Apr 17 '17 at 14:49






  • 1




    I still see a lot of dots in the single line of code. Try to avoid them.
    – Eugene Astafiev
    Apr 17 '17 at 14:54



















0














Updated (working) code based on Eugene's feedback:



Sub GetDetails(olMail As MailItem)
Dim oRecipients As Recipients
Dim oRecipient As Recipient
Dim oMembers As AddressEntries
Dim oMember As AddressEntry
Dim i As Integer, j As Integer, dRecCnt As Integer, dMemCnt As Integer

Set oRecipients = olMail.Recipients

dRecCnt = oRecipients.Count
For i = 1 To dRecCnt
Set oRecipient = oRecipients.Item(i)

If oRecipient.AddressEntry.GetExchangeUser Is Nothing Then
Set oMembers = oRecipient.AddressEntry.Members

dMemCnt = oMembers.Count
For j = 1 To dMemCnt
Set oMember = oMembers.Item(j)

Debug.Print c & ": " & oMember.GetExchangeUser.FirstName

Set oMember = Nothing
Next j

Set oMembers = Nothing
End If

Set oRecipient = Nothing
Next i

Set oRecipients = Nothing
End Sub





share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f43418692%2foutlook-distribution-list-member-details%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    You need to release Outlook COM objects instantly in the code. This is particularly important if your add-in attempts to enumerate more than 256 Outlook items in a collection that is stored on a Microsoft Exchange Server. If you do not release these objects in a timely manner, you can reach the limit imposed by Exchange on the maximum number of items opened at any one time. When you are done, just set a variable to Nothing to release the reference to the object.






    share|improve this answer





















    • Issue occurs after few iterations (~10). Releasing objects Dim o Set o = olMail.Recipients.Item(i).AddressEntry.Members.Item(j) Debug.Print o.GetExchangeUser.FirstName Set o = Nothing doesn't help.
      – Michał Malus
      Apr 17 '17 at 12:55








    • 1




      I see a lot of dots in the single line of code. So, I'd suggest breaking the chain of property and methods calls and declare them on separate line (each property or method on a single line of code). Thus you will be able to release them in a timely manner.
      – Eugene Astafiev
      Apr 17 '17 at 14:00










    • It may be the Members object that needs releasing, not the Item object...
      – David Zemens
      Apr 17 '17 at 14:42










    • I agree but that doesn't resolve the issue. It seems that the AddressEntry is resolved locally and AddressEntry.Members on the server hitting some limits for big DLs.
      – Michał Malus
      Apr 17 '17 at 14:49






    • 1




      I still see a lot of dots in the single line of code. Try to avoid them.
      – Eugene Astafiev
      Apr 17 '17 at 14:54
















    1














    You need to release Outlook COM objects instantly in the code. This is particularly important if your add-in attempts to enumerate more than 256 Outlook items in a collection that is stored on a Microsoft Exchange Server. If you do not release these objects in a timely manner, you can reach the limit imposed by Exchange on the maximum number of items opened at any one time. When you are done, just set a variable to Nothing to release the reference to the object.






    share|improve this answer





















    • Issue occurs after few iterations (~10). Releasing objects Dim o Set o = olMail.Recipients.Item(i).AddressEntry.Members.Item(j) Debug.Print o.GetExchangeUser.FirstName Set o = Nothing doesn't help.
      – Michał Malus
      Apr 17 '17 at 12:55








    • 1




      I see a lot of dots in the single line of code. So, I'd suggest breaking the chain of property and methods calls and declare them on separate line (each property or method on a single line of code). Thus you will be able to release them in a timely manner.
      – Eugene Astafiev
      Apr 17 '17 at 14:00










    • It may be the Members object that needs releasing, not the Item object...
      – David Zemens
      Apr 17 '17 at 14:42










    • I agree but that doesn't resolve the issue. It seems that the AddressEntry is resolved locally and AddressEntry.Members on the server hitting some limits for big DLs.
      – Michał Malus
      Apr 17 '17 at 14:49






    • 1




      I still see a lot of dots in the single line of code. Try to avoid them.
      – Eugene Astafiev
      Apr 17 '17 at 14:54














    1












    1








    1






    You need to release Outlook COM objects instantly in the code. This is particularly important if your add-in attempts to enumerate more than 256 Outlook items in a collection that is stored on a Microsoft Exchange Server. If you do not release these objects in a timely manner, you can reach the limit imposed by Exchange on the maximum number of items opened at any one time. When you are done, just set a variable to Nothing to release the reference to the object.






    share|improve this answer












    You need to release Outlook COM objects instantly in the code. This is particularly important if your add-in attempts to enumerate more than 256 Outlook items in a collection that is stored on a Microsoft Exchange Server. If you do not release these objects in a timely manner, you can reach the limit imposed by Exchange on the maximum number of items opened at any one time. When you are done, just set a variable to Nothing to release the reference to the object.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Apr 16 '17 at 17:27









    Eugene Astafiev

    18.1k21024




    18.1k21024












    • Issue occurs after few iterations (~10). Releasing objects Dim o Set o = olMail.Recipients.Item(i).AddressEntry.Members.Item(j) Debug.Print o.GetExchangeUser.FirstName Set o = Nothing doesn't help.
      – Michał Malus
      Apr 17 '17 at 12:55








    • 1




      I see a lot of dots in the single line of code. So, I'd suggest breaking the chain of property and methods calls and declare them on separate line (each property or method on a single line of code). Thus you will be able to release them in a timely manner.
      – Eugene Astafiev
      Apr 17 '17 at 14:00










    • It may be the Members object that needs releasing, not the Item object...
      – David Zemens
      Apr 17 '17 at 14:42










    • I agree but that doesn't resolve the issue. It seems that the AddressEntry is resolved locally and AddressEntry.Members on the server hitting some limits for big DLs.
      – Michał Malus
      Apr 17 '17 at 14:49






    • 1




      I still see a lot of dots in the single line of code. Try to avoid them.
      – Eugene Astafiev
      Apr 17 '17 at 14:54


















    • Issue occurs after few iterations (~10). Releasing objects Dim o Set o = olMail.Recipients.Item(i).AddressEntry.Members.Item(j) Debug.Print o.GetExchangeUser.FirstName Set o = Nothing doesn't help.
      – Michał Malus
      Apr 17 '17 at 12:55








    • 1




      I see a lot of dots in the single line of code. So, I'd suggest breaking the chain of property and methods calls and declare them on separate line (each property or method on a single line of code). Thus you will be able to release them in a timely manner.
      – Eugene Astafiev
      Apr 17 '17 at 14:00










    • It may be the Members object that needs releasing, not the Item object...
      – David Zemens
      Apr 17 '17 at 14:42










    • I agree but that doesn't resolve the issue. It seems that the AddressEntry is resolved locally and AddressEntry.Members on the server hitting some limits for big DLs.
      – Michał Malus
      Apr 17 '17 at 14:49






    • 1




      I still see a lot of dots in the single line of code. Try to avoid them.
      – Eugene Astafiev
      Apr 17 '17 at 14:54
















    Issue occurs after few iterations (~10). Releasing objects Dim o Set o = olMail.Recipients.Item(i).AddressEntry.Members.Item(j) Debug.Print o.GetExchangeUser.FirstName Set o = Nothing doesn't help.
    – Michał Malus
    Apr 17 '17 at 12:55






    Issue occurs after few iterations (~10). Releasing objects Dim o Set o = olMail.Recipients.Item(i).AddressEntry.Members.Item(j) Debug.Print o.GetExchangeUser.FirstName Set o = Nothing doesn't help.
    – Michał Malus
    Apr 17 '17 at 12:55






    1




    1




    I see a lot of dots in the single line of code. So, I'd suggest breaking the chain of property and methods calls and declare them on separate line (each property or method on a single line of code). Thus you will be able to release them in a timely manner.
    – Eugene Astafiev
    Apr 17 '17 at 14:00




    I see a lot of dots in the single line of code. So, I'd suggest breaking the chain of property and methods calls and declare them on separate line (each property or method on a single line of code). Thus you will be able to release them in a timely manner.
    – Eugene Astafiev
    Apr 17 '17 at 14:00












    It may be the Members object that needs releasing, not the Item object...
    – David Zemens
    Apr 17 '17 at 14:42




    It may be the Members object that needs releasing, not the Item object...
    – David Zemens
    Apr 17 '17 at 14:42












    I agree but that doesn't resolve the issue. It seems that the AddressEntry is resolved locally and AddressEntry.Members on the server hitting some limits for big DLs.
    – Michał Malus
    Apr 17 '17 at 14:49




    I agree but that doesn't resolve the issue. It seems that the AddressEntry is resolved locally and AddressEntry.Members on the server hitting some limits for big DLs.
    – Michał Malus
    Apr 17 '17 at 14:49




    1




    1




    I still see a lot of dots in the single line of code. Try to avoid them.
    – Eugene Astafiev
    Apr 17 '17 at 14:54




    I still see a lot of dots in the single line of code. Try to avoid them.
    – Eugene Astafiev
    Apr 17 '17 at 14:54













    0














    Updated (working) code based on Eugene's feedback:



    Sub GetDetails(olMail As MailItem)
    Dim oRecipients As Recipients
    Dim oRecipient As Recipient
    Dim oMembers As AddressEntries
    Dim oMember As AddressEntry
    Dim i As Integer, j As Integer, dRecCnt As Integer, dMemCnt As Integer

    Set oRecipients = olMail.Recipients

    dRecCnt = oRecipients.Count
    For i = 1 To dRecCnt
    Set oRecipient = oRecipients.Item(i)

    If oRecipient.AddressEntry.GetExchangeUser Is Nothing Then
    Set oMembers = oRecipient.AddressEntry.Members

    dMemCnt = oMembers.Count
    For j = 1 To dMemCnt
    Set oMember = oMembers.Item(j)

    Debug.Print c & ": " & oMember.GetExchangeUser.FirstName

    Set oMember = Nothing
    Next j

    Set oMembers = Nothing
    End If

    Set oRecipient = Nothing
    Next i

    Set oRecipients = Nothing
    End Sub





    share|improve this answer




























      0














      Updated (working) code based on Eugene's feedback:



      Sub GetDetails(olMail As MailItem)
      Dim oRecipients As Recipients
      Dim oRecipient As Recipient
      Dim oMembers As AddressEntries
      Dim oMember As AddressEntry
      Dim i As Integer, j As Integer, dRecCnt As Integer, dMemCnt As Integer

      Set oRecipients = olMail.Recipients

      dRecCnt = oRecipients.Count
      For i = 1 To dRecCnt
      Set oRecipient = oRecipients.Item(i)

      If oRecipient.AddressEntry.GetExchangeUser Is Nothing Then
      Set oMembers = oRecipient.AddressEntry.Members

      dMemCnt = oMembers.Count
      For j = 1 To dMemCnt
      Set oMember = oMembers.Item(j)

      Debug.Print c & ": " & oMember.GetExchangeUser.FirstName

      Set oMember = Nothing
      Next j

      Set oMembers = Nothing
      End If

      Set oRecipient = Nothing
      Next i

      Set oRecipients = Nothing
      End Sub





      share|improve this answer


























        0












        0








        0






        Updated (working) code based on Eugene's feedback:



        Sub GetDetails(olMail As MailItem)
        Dim oRecipients As Recipients
        Dim oRecipient As Recipient
        Dim oMembers As AddressEntries
        Dim oMember As AddressEntry
        Dim i As Integer, j As Integer, dRecCnt As Integer, dMemCnt As Integer

        Set oRecipients = olMail.Recipients

        dRecCnt = oRecipients.Count
        For i = 1 To dRecCnt
        Set oRecipient = oRecipients.Item(i)

        If oRecipient.AddressEntry.GetExchangeUser Is Nothing Then
        Set oMembers = oRecipient.AddressEntry.Members

        dMemCnt = oMembers.Count
        For j = 1 To dMemCnt
        Set oMember = oMembers.Item(j)

        Debug.Print c & ": " & oMember.GetExchangeUser.FirstName

        Set oMember = Nothing
        Next j

        Set oMembers = Nothing
        End If

        Set oRecipient = Nothing
        Next i

        Set oRecipients = Nothing
        End Sub





        share|improve this answer














        Updated (working) code based on Eugene's feedback:



        Sub GetDetails(olMail As MailItem)
        Dim oRecipients As Recipients
        Dim oRecipient As Recipient
        Dim oMembers As AddressEntries
        Dim oMember As AddressEntry
        Dim i As Integer, j As Integer, dRecCnt As Integer, dMemCnt As Integer

        Set oRecipients = olMail.Recipients

        dRecCnt = oRecipients.Count
        For i = 1 To dRecCnt
        Set oRecipient = oRecipients.Item(i)

        If oRecipient.AddressEntry.GetExchangeUser Is Nothing Then
        Set oMembers = oRecipient.AddressEntry.Members

        dMemCnt = oMembers.Count
        For j = 1 To dMemCnt
        Set oMember = oMembers.Item(j)

        Debug.Print c & ": " & oMember.GetExchangeUser.FirstName

        Set oMember = Nothing
        Next j

        Set oMembers = Nothing
        End If

        Set oRecipient = Nothing
        Next i

        Set oRecipients = Nothing
        End Sub






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Apr 17 '17 at 15:23

























        answered Apr 17 '17 at 15:14









        Michał Malus

        216




        216






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f43418692%2foutlook-distribution-list-member-details%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

            Calculate evaluation metrics using cross_val_predict sklearn

            Insert data from modal to MySQL (multiple modal on website)