OL Kontaktordner mit VBA ansprechen
Geizhals » Forum » Programmierung » OL Kontaktordner mit VBA ansprechen (7 Beiträge, 167 Mal gelesen) Top-100 | Fresh-100
Du bist nicht angemeldet. [ Login/Registrieren ]
OL Kontaktordner mit VBA ansprechen
25.08.2006, 14:18:03
Hallo !
Ich habe eine EXCEL Adressenliste die in einen Kontakte Ordner namens "Verteilerlisten" reinkopiert werden soll !
Derzeit schaffe ich es nur die Daten in den *TRÖT* "Kontakte" Ordner zu löschen/kopieren.
Wie müßte ich den Code anpassen, dass er die Routine auf den
"Verteilerlisten" Ordner anwendet ?

Danke
lg
Philipp

[Code]

Sub OutlookKontakte()
'
' OutlookKontakte Makro
' AKHEDXKAP
'

Dim olApp As Outlook.Application
Dim objNameSpace As Outlook.NameSpace
Dim objKontaktOrdner As MAPIFolder
Dim objKontakt As Outlook.ContactItem
Dim i As Integer
On Error Resume Next
Set olApp = CreateObject("Outlook.Application")
Set objNameSpace = olApp.GetNamespace("MAPI")
Set objKontaktOrdner = objNameSpace.GetDefaultFolder(olFolderContacts)
Do
  i = 0
  For Each objKontakt In objKontaktOrdner.Items
    If objKontakt.Sensitivity <> olPrivate Then
      objKontakt.Delete
    Else
      i = i + 1
    End If
  Next
Loop Until objKontaktOrdner.Items.Count = i

Set objKontakt = Nothing
Set objKontaktOrdner = Nothing
Set olApp = Nothing
On Error GoTo 0

'Kontakte anlegen'

    Dim appOutLook As Outlook.Application
    Dim conoutlook As Outlook.ContactItem
    Set appOutLook = CreateObject("Outlook.Application")

    Range("A2").Select

    Do Until ActiveCell.Value = ""
    Set conoutlook = appOutLook.CreateItem(olContactItem)
    With conoutlook
        .FirstName = ActiveCell.Value
        .LastName = ActiveCell.Offset(0, 1).Value
        .BusinessAddress = ActiveCell.Offset(0, 2).Value & ", " & ActiveCell.Offset(0, 3).Value
        .BusinessAddressCountry = ActiveCell.Offset(0, 4).Value
        .BusinessAddressPostalCode = ActiveCell.Offset(0, 5).Value
        .BusinessAddressState = ActiveCell.Offset(0, 6).Value
        .Email1Address = ActiveCell.Offset(0, 7).Value
        .HomeTelephoneNumber = ActiveCell.Offset(0, 8).Value
        .BusinessTelephoneNumber = ActiveCell.Offset(0, 9).Value
        .BusinessFaxNumber = ActiveCell.Offset(0, 10).Value
        .Save
    End With
    ActiveCell.Offset(1, 0).Select
    Loop

    Set conoutlook = Nothing
    Set appOutLook = Nothing

End Sub

[/Code]

Antworten PM Übersicht Chronologisch
 
Melden nicht möglich
 

Dieses Forum ist eine frei zugängliche Diskussionsplattform.
Der Betreiber übernimmt keine Verantwortung für den Inhalt der Beiträge und behält sich das Recht vor, Beiträge mit rechtswidrigem oder anstößigem Inhalt zu löschen.
Datenschutzerklärung