How to Update the Outlook Global Address Distribution List in VB

How to Update the Outlook Global Address Distribution List in VB thumbnail
Global Address Distribution Lists help companies keep track of large email lists.

Companies sending mass emails to large groups of people may find it helpful to keep updated records of their distribution lists. Microsoft Outlook includes this feature as the Global Address Distribution List. You can update such a list several ways, but one of the easiest is through Visual Basic, or VB. Because VB runs off individual commands rather than back-and-forth interactivity, updating the list requires writing a new list over the old.

Instructions

    • 1

      Open VB.

    • 2

      Select "New" from the File menu. Click "Project" in the window that appears.

    • 3

      Check the boxes marked "Visual Basic Projects" and "Console Application," then click "OK." This creates the window that allows you to enter the distribution list code.

    • 4

      Select "Add Reference" from the Project menu at the top of the screen.

    • 5

      Click the "COM" tab.

    • 6

      Double-click "Microsoft Outlook XX Object Library." The "XX" will say your version of Outlook (i.e., 10.0, 9.1). Click "OK."

    • 7

      Click anywhere in the project window that has appeared and press "Ctrl"+"A" to select all of the text. Press the "Delete" key. You will be replacing this generic code to open Outlook with the distribution list code.

    • 8

      Copy and paste the following into the window. Do not press "Enter."

      Imports System.Reflection

      Module Module1

      Sub Main()

      ' Create Outlook application.

      Dim oApp As Outlook.Application = New Outlook.Application()

      ' Get Mapi NameSpace and Logon.

      Dim oNS As Outlook.NameSpace = oApp.GetNamespace("mapi")

      oNS.Logon("YourValidProfile", Missing.Value, False, True) ' [TO DO]:

      ' Get Global Address List.

      Dim oDLs As Outlook.AddressLists = oNS.AddressLists

      Dim oGal As Outlook.AddressList = oDLs.Item("Global Address List")

      Console.WriteLine(oGal.Name)

      ' Get a specific distribution list.

      ' [TO DO]

      Dim sDL As String = "TestDL"

      Dim oEntries As Outlook.AddressEntries = oGal.AddressEntries

      ' No filter available to AddressEntries

      Dim oDL As Outlook.AddressEntry = oEntries.Item(sDL)

      Console.WriteLine(oDL.Name)

      Console.WriteLine(oDL.Address)

      Console.WriteLine(oDL.Manager)

      ' Get all of the members of the distribution list.

      oEntries = oDL.Members

      Dim oEntry As Outlook.AddressEntry

      Dim i As Integer

      For i = 1 To oEntries.Count

      oEntry = oEntries.Item(i)

      Console.WriteLine(oEntry.Name)

      ' Display the Details dialog box.

      'oDL.Details(Missing.Value)

      Next

      ' Log off.

      oNS.Logoff()

      ' Clean up.

      oApp = Nothing

      oNS = Nothing

      oDLs = Nothing

      oGal = Nothing

      oEntries = Nothing

      oEntry = Nothing

      End Sub

      End Module

    • 9

      Replace the first "[TO DO]" with your Outlook password.

    • 10

      Replace the second "[TO DO]" with the location to save the list. To save to the Desktop, for instance, type "C:\Desktop" (no quotes).

    • 11

      Press "Enter" to create an updated version of the list.

Related Searches:

References

  • Photo Credit computer monitor with lots of mail image by patrimonio designs from Fotolia.com

Comments

You May Also Like

Related Ads

Featured