Live-Forum - Die aktuellen Beiträge
Anzeige
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

Outlook Kontakte

Forumthread: Outlook Kontakte

Outlook Kontakte
17.09.2002 10:58:53
Markus
Hey!
Ich kapier das einfach nicht.
Axel hat mir schon weitergeholfen aber jetzt steh ich wirklich an.
Ich kann kein benutzerdefiniertes Feld aus meinen Kontakten auslesen. (z.b. Versichert bei:)
Sonst funktioniert alles mit dem folgendem Code:

Option Explicit

Sub Kontakte()
Dim olAppl As Outlook.Application
Dim olNS As Outlook.NameSpace
Dim olMAPIFolder As Outlook.MAPIFolder
Dim olItems As Outlook.Items
Dim olResItems As Outlook.Items
Dim olContact As Outlook.ContactItem
Dim intCounter As Integer
Dim sFilter As String

On Error GoTo byebye

Set olAppl = CreateObject("Outlook.Application")
Set olNS = olAppl.GetNamespace("MAPI")
Set olMAPIFolder = olNS.GetDefaultFolder(olFolderContacts)
Set olItems = olMAPIFolder.Items

sFilter = "[MessageClass] = 'IPM.Contact'"

Set olResItems = olItems.Restrict(sFilter)


Dim a As Variant
Set a = olContact
For Each olContact In olResItems

intCounter = intCounter + 1

Cells(intCounter, 1) = olContact.Birthday
Cells(intCounter, 2) = olContact.FirstName
Cells(intCounter, 3) = olContact.LastName

Next olContact

byebye:
Set olResItems = Nothing
Set olItems = Nothing
Set olMAPIFolder = Nothing
Set olNS = Nothing
Set olAppl = Nothing

Exit Sub

End Sub

Kann mir jemand helfen?

Danke im vorhinein!

Anzeige

1
Beitrag zum Forumthread
Beitrag zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
Re: Outlook Kontakte
17.09.2002 16:48:07
Markus
Habs nach langem Probieren jetzt doch selber geschafft:

Option Explicit

Sub Kontakte()
Dim olAppl As Outlook.Application
Dim olNS As Outlook.NameSpace
Dim olMAPIFolder As Outlook.MAPIFolder
Dim olItems As Outlook.Items
Dim olResItems As Outlook.Items
Dim olContact As Outlook.ContactItem
Dim intCounter As Integer
Dim sFilter As String

On Error GoTo byebye

Set olAppl = CreateObject("Outlook.Application")

Set olNS = olAppl.GetNamespace("MAPI")
Set olMAPIFolder = olNS.GetDefaultFolder(olFolderContacts)


Set olItems = olMAPIFolder.Items

Dim intIndex As Integer

sFilter = "[MessageClass] = 'IPM.Contact'"

Set olResItems = olItems.Restrict(sFilter)


Dim a As Variant
Dim strValue As String

Set a = olContact
For Each olContact In olResItems

strValue = GetUserProperty(olContact, "Test")

If Len(Trim(strValue)) > 0 Then
Debug.Print strValue
End If

intCounter = intCounter + 1

Cells(intCounter, 1) = olContact.Birthday
Cells(intCounter, 2) = olContact.FirstName
Cells(intCounter, 3) = olContact.LastName
Cells(intCounter, 4) = strValue

Next olContact

byebye:
Set olResItems = Nothing
Set olItems = Nothing
Set olMAPIFolder = Nothing
Set olNS = Nothing
Set olAppl = Nothing

Exit Sub

End Sub

Private Function GetUserProperty(ByVal olContact As Outlook.ContactItem, _
ByVal strPropName As String) As String
On Error GoTo ErrorCheck

Dim strResult As String

strResult = CStr(olContact.UserProperties(strPropName))

ExitLabel:
GetUserProperty = strResult
Exit Function

ErrorCheck:
strResult = vbNullString
Resume ExitLabel

End Function

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Entdecke mehr
Finde genau, was du suchst

Die erweiterte Suchfunktion hilft dir, gezielt die besten Antworten zu finden

Suche nach den besten Antworten
Unsere beliebtesten Threads

Entdecke unsere meistgeklickten Beiträge in der Google Suche

Top 100 Threads jetzt ansehen
Anzeige