?
=?iso-8859-1?Q?Cyrill_H=E4feli?=
I have this code:
Dim ol As New Outlook.Application
Dim olns As Outlook.Namespace
Dim cf As Outlook.MAPIFolder
Dim c As Outlook.ContactItem
Dim Prop As Outlook.UserProperties
Set olns = ol.GetNamespace("MAPI")
Set cf = olns.GetSharedDefaultFolder(olFolderContacts)
With rst
.MoveFirst
' DAO Objects setzen
Dim oDataBase As DAO.Database
Dim rst As DAO.Recordset
Set oDataBase = OpenDatabase _
("C:\\Data.MDB")
Set rst = oDataBase.OpenRecordset("Outlook")
' Loop
Do While Not .EOF
' Erstellt einen neuen Kontakt
Set c = ol.CreateItem(olContactItem)
' Spezifikation
c.MessageClass = "IPM.Contact"
' Erstellt alle benötigten Outlook Felder
If ![AdresseFirma] <> "" Then c.CompanyName = ![AdresseFirma]
If ![AdresseName] <> "" Then c.LastName = ![AdresseName]
If ![AdresseVorname] <> "" Then c.FirstName = ![AdresseVorname]
If ![AdresseEMAil] <> "" Then c.Email1Address = ![AdresseEMAil]
If ![AdressePLZ] <> "" Then c.HomeAddressPostalCode = ![AdressePLZ]
If ![AdresseOrt] <> "" Then c.HomeAddressCity = ![AdresseOrt]
If ![AdresseAdresse] <> "" Then c.HomeAddressStreet = ![AdresseAdresse]
If ![AdresseTelefonPrivat] <> "" Then c.HomeTelephoneNumber = ![AdresseTelefonPrivat]
If ![AdresseTelefonGeschäft] <> "" Then c.BusinessTelephoneNumber = ![AdresseTelefonGeschäft]
If ![AdresseTelefax] <> "" Then c.BusinessFaxNumber = ![AdresseTelefax]
If ![AdresseNatel] <> "" Then c.MobileTelephoneNumber = ![AdresseNatel]
If ![AdresseBeruf] <> "" Then c.JobTitle = ![AdresseBeruf]
If ![AdresseWWW] <> "" Then c.WebPage = ![AdresseWWW]
' Erstellt UserFeld 1, wird wie "ID" angewendet.
Set Prop = c.UserProperties.Add("UserField1", olText)
If ![PersonID] <> "" Then Prop = ![PersonID]
' Erstellt UserFeld 2
Set Prop = c.UserProperties.Add("UserField2", olText)
' Hier kann man weiter Felder setzen
If ![AdresseOrt] <> "" Then Prop = ![AdresseOrt]
' Speichert den Kontakt
c.Save
.MoveNext
Loop
End With
And i want, when its new then CREATE, ELSE i want edit the Contact Fields
You now what i mean?
You have an Answer for me
Thx
Cyrill
Dim ol As New Outlook.Application
Dim olns As Outlook.Namespace
Dim cf As Outlook.MAPIFolder
Dim c As Outlook.ContactItem
Dim Prop As Outlook.UserProperties
Set olns = ol.GetNamespace("MAPI")
Set cf = olns.GetSharedDefaultFolder(olFolderContacts)
With rst
.MoveFirst
' DAO Objects setzen
Dim oDataBase As DAO.Database
Dim rst As DAO.Recordset
Set oDataBase = OpenDatabase _
("C:\\Data.MDB")
Set rst = oDataBase.OpenRecordset("Outlook")
' Loop
Do While Not .EOF
' Erstellt einen neuen Kontakt
Set c = ol.CreateItem(olContactItem)
' Spezifikation
c.MessageClass = "IPM.Contact"
' Erstellt alle benötigten Outlook Felder
If ![AdresseFirma] <> "" Then c.CompanyName = ![AdresseFirma]
If ![AdresseName] <> "" Then c.LastName = ![AdresseName]
If ![AdresseVorname] <> "" Then c.FirstName = ![AdresseVorname]
If ![AdresseEMAil] <> "" Then c.Email1Address = ![AdresseEMAil]
If ![AdressePLZ] <> "" Then c.HomeAddressPostalCode = ![AdressePLZ]
If ![AdresseOrt] <> "" Then c.HomeAddressCity = ![AdresseOrt]
If ![AdresseAdresse] <> "" Then c.HomeAddressStreet = ![AdresseAdresse]
If ![AdresseTelefonPrivat] <> "" Then c.HomeTelephoneNumber = ![AdresseTelefonPrivat]
If ![AdresseTelefonGeschäft] <> "" Then c.BusinessTelephoneNumber = ![AdresseTelefonGeschäft]
If ![AdresseTelefax] <> "" Then c.BusinessFaxNumber = ![AdresseTelefax]
If ![AdresseNatel] <> "" Then c.MobileTelephoneNumber = ![AdresseNatel]
If ![AdresseBeruf] <> "" Then c.JobTitle = ![AdresseBeruf]
If ![AdresseWWW] <> "" Then c.WebPage = ![AdresseWWW]
' Erstellt UserFeld 1, wird wie "ID" angewendet.
Set Prop = c.UserProperties.Add("UserField1", olText)
If ![PersonID] <> "" Then Prop = ![PersonID]
' Erstellt UserFeld 2
Set Prop = c.UserProperties.Add("UserField2", olText)
' Hier kann man weiter Felder setzen
If ![AdresseOrt] <> "" Then Prop = ![AdresseOrt]
' Speichert den Kontakt
c.Save
.MoveNext
Loop
End With
And i want, when its new then CREATE, ELSE i want edit the Contact Fields
You now what i mean?
You have an Answer for me
Thx
Cyrill