![]() |
Tipp 0192
|
Outlook 2000 - Kontakt hinzufügen
|
 |
|
Autor/Einsender: Datum: |
|
Angie 27.01.2002 |
|
Entwicklungsumgebung: |
|
VB 5 |
|
|
Das Adressbuch in Outlook 2000 wird durch den Kontakte-Ordner repräsentiert. In diesem Beispiel wird über die
GetDefaultFolder-Eigenschaft des NameSpace-Objekts MAPI (Messaging Application Programming Interface)
ein Kontakt (ContactItem-Objekt) zum Adressbuch hinzugefügt.
|
|
|
Option Explicit
Private Sub cmdKontaktHinzufuegen_Click()
Dim olAppl As Outlook.Application
Dim olNS As Outlook.NameSpace
Dim olMAPIFolder As Outlook.MAPIFolder
Dim olContact As Outlook.ContactItem
On Error GoTo errMsgOL
Set olAppl = CreateObject("Outlook.Application")
Set olNS = olAppl.GetNamespace("MAPI")
Set olMAPIFolder = olNS.GetDefaultFolder(olFolderContacts)
Set olContact = olMAPIFolder.Items.Add
With olContact
.Categories = txtKategorie.Text
.LastName = txtName.Text
.FirstName = txtVorname.Text
.HomeAddressStreet = txtStrasse.Text
.HomeAddressPostalCode = txtPLZ.Text
.HomeAddressCity = txtOrt.Text
.Email1Address = txtEmail.Text
.Save
End With
byebye:
Set olContact = Nothing
Set olMAPIFolder = Nothing
Set olNS = Nothing
Set olAppl = Nothing
Exit Sub
errMsgOL:
MsgBox "Es ist ein Fehler beim Zugriff auf Outlook " & _
aufgetreten!", vbCritical
Resume byebye
End Sub
|
|
|
|
Um diesen Tipp ausführen zu können, muss Outlook installiert sein und zur Entwurfszeit die Microsoft Outlook x.0 Object Library in das
Projekt eingebunden werden.
|
Bei Late Binding wird zur Entwurfszeit kein Verweis auf die Objektbibliothek in das Projekt eingebunden.
Alle verwendeten Objekte werden mit dem Variablentyp Object definiert. Ggf. verwendete anwendungsspezifische Konstanten
müssen mit dem entsprechenden numerischen Äquivalent der Konstante ersetzt werden, könnten aber auch mit der Const-Anweisung
deklariert werden. Die Verwendung von Konstanten erleichtert das Dokumentieren und Modifizieren Ihrer Programme, und trägt auch zur besseren
Lesbarkeit des Codes bei.
|
|
|
|
Microsoft Links zum Thema |
|
|
Windows-Version |
95 |
 |
|
98/SE |
 |
|
ME |
 |
|
NT |
 |
|
2000 |
 |
|
XP |
 |
|
Vista |
 |
|
Win
7 |
 |
|
|
VB-Version |
VBA 5 |
 |
|
VBA 6 |
 |
|
VB 4/16 |
 |
|
VB 4/32 |
 |
|
VB 5 |
 |
|
VB 6 |
 |
|
|
|
Download (2,5 kB)
|
Downloads bisher: [ 1291 ]
|
|
|