Results 1 to 4 of 4

Thread: Outlook - How to verify if a distribution list exist

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2018
    Posts
    514

    Outlook - How to verify if a distribution list exist

    Hi,
    I need to find method to verify if a mail group/distribution list exist in Outlook addresslist.

    so far... I am no where and just started to import the Outlook interrupt library. I am trying to get the content of "Microsoft.Office.Interop.Outlook.ExchangeDistributionList" to see that brings me some insight.


    Any help is appreciated.

    Thanks.

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Outlook - How to verify if a distribution list exist

    you can try like
    Code:
    Set mycontacts = Session.GetDefaultFolder(olFolderContacts)
    For Each itm In mycontacts.Items
        If TypeName(itm) = "DistListItem" Then MsgBox "one or more distribution list exists"
    Next
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2018
    Posts
    514

    Re: Outlook - How to verify if a distribution list exist

    Thanks.
    Is there any alternative to "Set"? My code editor says it is no longer supported.
    I tried Dim mycontacts As Object = Session.GetDefaultFolder(olFolderContacts)
    but now both "Session" and "olFolderContacts" are red-underlined

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Outlook - How to verify if a distribution list exist

    just omit the set keyword
    but now both "Session" and "olFolderContacts" are red-underlined
    as you are working from .net, you should use your outlook introp object something like
    Code:
    mycontacts = objolook.Session.GetDefaultFolder(olFolderContacts)
    olFolderContacts is an outlook constant, it should also be in your interop items, else its literal value is 10

    i have never tried programming outlook from vb.net, so can not give exact example
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Posting Permissions

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



Click Here to Expand Forum to Full Width