habe eine Exceltabelle mit Kontaktdaten, die in eine Outlook-Verteilerliste überführt werden sollen. Soweit so gut, aber wie bekomme ich das hin, dass die Verteilerliste aktualisiert wird. Überschreiben macht er nicht, stattdessen wird die erneut angelegt. Hatte die Idee zunächst die alte Liste zu löschen, aber finde keinen passenden Code.
So sieht er bisher aus:
Sub Verteilerliste()
Dim appOutlook As New Outlook.Application
Dim objNS As Outlook.Namespace
Dim objFolder As Object
Dim objDistList As Outlook.DistListItem
Dim objMail As MailItem
Dim objRcpnts As Recipients
Dim objRcpnt As Recipient
Dim i As Long
Set objNS = appOutlook.GetNamespace("MAPI")
Set objFolder = objNS.GetDefaultFolder(olFolderContacts)
Set objMail = appOutlook.CreateItem(Outlook.OlItemType.olMailItem)
Set objRcpnts = objMail.Recipients
With ThisWorkbook.Sheets("Aktive Nutzer")
For i = 2 To .Cells(.Rows.Count, 1).End(xlUp).Row
Set objRcpnt = objRcpnts.Add(" " & .Cells(i, 11))
Next
End With
Set objDistList = objFolder.Items.Add(Outlook.OlItemType.olDistributionListItem)
objDistList.DLName = "test"
objDistList.AddMembers objRcpnts
objDistList.Save
Set objDistList = Nothing
Set objRcpnt = Nothing
Set objRcpnts = Nothing
Set objMail = Nothing
Set objFolder = Nothing
Set objNS = Nothing
Set appOutlook = Nothing
End Sub
Danke schonmalMatthias