Creating a DistList from a .txt file

N

NateG

Ok,

Here's my addList Function that actually works very nicely:

Private Sub addList(ByVal listName As String, ByVal memberList() As String,
ByVal memberEmails() As String)
Dim oApp As Outlook.Application
Dim oNS As Outlook.NameSpace
Dim oDL As Outlook.DistListItem
Dim i As Integer
Dim oRecipient As Outlook.Recipient

oApp = CreateObject("Outlook.Application")
oNS = oApp.GetNamespace("MAPI")
oDL = oApp.CreateItem(Outlook.OlItemType.olDistributionListItem)
oDL.DLName = listName
oDL.Save()

For i = 0 To UBound(memberEmails)
If memberList(i) = Nothing Then
Exit For
End If
oRecipient = oNS.CreateRecipient(memberList(i) & "<" &
memberEmails(i) & ">")
oRecipient.Resolve()
oDL.AddMember(oRecipient)
oDL.Save()
Next

oDL.Save()

'Clean up
oApp = Nothing
oNS = Nothing
oDL = Nothing
oRecipient = Nothing

End Sub

Let me know what I need to do to give you guys credit, like forum points or
whatever they give you guys for helping out. I'd love to return the favor.
 
N

NateG

I posted the final code as a reply to one of Ken's posts. Thanks for all the
help, let me know if there's anything I can do to give you guys more like,
forum points, or whatever the reward is for helping out on these forums.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top