Results 1 to 9 of 9
  1. #1
    New Lounger
    Join Date
    May 2003
    Location
    Grand Rapids, Michigan, USA
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Outlook VBA - create & append names to dist list (Outlook XP(2002))

    <img src=/S/confused.gif border=0 alt=confused width=15 height=20>
    I've been wrestling with this one for a week. I need to create a distribution list called "All Contacts" in a folder called "Imported" BELOW the Contacts folder, then add all the contacts that are within that folder to the distribution list.

    I've automated the creation of a Folder under Contacts called "Imported", and am able to import the names there. But when I create a distribution list, it's always created under the Contacts folder, Not the ContactsImported folder. And none of the names are being added to the distribution list.

    I've tried a google search & ms search... tried a lot of options to no avail.

    Here's my distribution list code...

    Dim myOlApp As Application
    Set myDistList = myOlApp.CreateItem(olDistributionListItem)

    myDistList.DLName = "All Contacts"
    myDistList

    'The MailItem is required to create the Recipients collection
    Set myMailItem = myOlApp.CreateItem(olMailItem)
    Set MyRecipients = myMailItem.Recipients

    'A Contact with the following e-mail address must exist for the AddMembers method to work
    MyRecipients.Add "username@domain.com"
    MyRecipients.ResolveAll
    myDistList.AddMembers MyRecipients
    myDistList.Save
    myDistList.Display

    Thanks for any help...

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Outlook VBA - create & append names to dist list (Outlook XP(2002))

    You can either create the item with CreateItem, and then move it from the default folder to your "Imported" subfolder, using the Move method, or you can create it using the Items.Add method of your "imported" folder. You can find information about Move and Add in the online help, but don't hesitate to post back if you need more assistance.

  3. #3
    New Lounger
    Join Date
    May 2003
    Location
    Grand Rapids, Michigan, USA
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Outlook VBA - create & append names to dist list (Outlook XP(2002))

    I've tried that. The problem is I don't know HOW to reference the subfolder.

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Outlook VBA - create & append names to dist list (Outlook XP(2002))

    This thread discusses ways to navigate the folders/subfolders tree. Does that help?

  5. #5
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Outlook VBA - create & append names to dist list (Outlook XP(2002))

    A clumsy way is to get the Folder EntryID from the Immediates window and then in the code reference the Folder with GetFolderFromID(<the obtained ID>), as I do <!post=here,312522>here<!/post>.
    -John ... I float in liquid gardens
    UTC -7ąDS

  6. #6
    New Lounger
    Join Date
    May 2003
    Location
    Grand Rapids, Michigan, USA
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Still no resolution

    Unfortunately, that thread just allows me to return the count of the items. I need to address the distribution list in the subfolder itself, then add the contacts. Any help would be appreciated.

  7. #7
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Still no resolution

    To my other post I should add that if you are creating this folder as part of the code, you can probably just hold it as a dimensioned object in the code, but if it already already exists, with the default Outlook Contact Folder as your starting point, you can can loop through all the subfolders as Jefferson suggests, and find the matching folder name.

    We might better be able to help if you post the entire code.
    -John ... I float in liquid gardens
    UTC -7ąDS

  8. #8
    Platinum Lounger
    Join Date
    Jan 2001
    Location
    Roanoke area, Virginia, USA
    Posts
    3,729
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Outlook VBA - create & append names to dist list (Outlook XP(2002))

    Use the form here http://www.cdolive.com/folderpropertyviewer.htm and run it to get the folder id. (It needs published to work with newer versions of OL.)

  9. #9
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Outlook VBA - create & append names to dist list (Outlook XP(2002))

    I have reviewed some of your code with a view to helping you, and have two questions:

    1. If this DL is called "All Contacts", do you want all recipients from a single selected message added to it? Otherwise you will have a problem creating this item anew as soon as it already exists.

    2. As written, the source of the DL is recipients from an e-mail Message that the procedure creates. How does the created Message get its recipients, or do you want to pull recipients from Messages you have received?
    -John ... I float in liquid gardens
    UTC -7ąDS

Posting Permissions

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