Creating a DistList from a .txt file

  • Thread starter Thread starter NateG
  • Start date Start date
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.
 
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.
 
Back
Top