Generating a Personal Distribution List in Contacts Programatically (Outlook 2003)

  • Thread starter Thread starter Don
  • Start date Start date
D

Don

Is there a way to generate distribution list in my personal contact list
programmatically? I know enough VBA to be dangerous and usually work MS
Access databases, so I think I can handle the programming. The problem for
me is understanding the Outlook programming model and what can and can't be
done.

Not sure if the source will be an Access database or Excel spreadsheet at
this point. However, I think I can handle getting the e-mail addresses into
the code, it's just getting them into the list.

Any ideas, pointers to samples, etc will be greatly appreciated!

Thanks!

Don
 
I am not clear on what you want to do. If you are trying to get all the
e-mail addresses for a distribution list I have seen a few simple ways to do
that. They lack the elegance and sophistication of VBA, but it works for
the unwashed among us, myself included, to whom VBA is a a form of cruel and
unusual punishment, the first two letters of which probably mean "very" and
"bad." I'm not sure what the third letter might mean and I probably am
better off not knowing. Anyway. If this is what you want, you can create a
new message and address it to your distribution list. If the list is not
"expanded" to show the many individual e-mail addresses, click on the plus
sign to the left of the name of the list. Click OK when warned that if you
expand the list you can condense it later. Here's where it gets really
simple. Highlight all the e-mail addresses and copy them into another
document in Office, e.g., a word of Word Pad document. It isn't pretty but
now you have a list of your e-mail addresses. Do some clean up and
formatting and nobody will realize you skipped the VBA stuff.

On the other hand, if this is not what you are looking for, somebody else
can surely give you a pointer or two. Even if it is, they can probably give
you more elegant ways to do it.
 
Am Tue, 25 Oct 2005 21:18:48 -0400 schrieb Don:

Don, here is sample for adding a member to a DL:

Public Function AddMember(oDL As Outlook.DistListItem, _
sName As String, _
sAdr As String _
) As Boolean
Dim oMail As Outlook.MailItem
Dim colRecips As Outlook.Recipients
Dim oRecip1 As Outlook.Recipient

Set oMail = oDL.Application.CreateItem(olMailItem)
Set colRecips = oMail.Recipients

' This adds a member linked to your contacts IF
' - The name is unique
' - and the contact has one e-mail address only!
Set oRecip1 = colRecips.Add(sName)
' This adds a member regardless if it´s from your contacts or not
' Set oRecip1 = colRecips.Add("<" & sName & "> " & sAdr)

If colRecips.ResolveAll Then
oDL.AddMembers colRecips
oDL.Save
AddMember = True
End If
End Sub
 
Michael,

Perfect! Your sample got me started and I am learning a bunch of new things
about Outlook!

Thanks!

Don
 
Can you give me an example of how this would run? I know the sName is the
person's name and the sAdr is their e-mail address. What goes in for "oDL As
Outlook.DistListItem"?

I have a list of e-mail addresses that I would like to put into a
distribution list. This list is generated weekly and a new distribution list
woul dneed to be created each time the list is run.
 
Back
Top