I must Update a Contact Item

  • Thread starter Thread starter =?iso-8859-1?Q?Cyrill_H=E4feli?=
  • Start date Start date
?

=?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
 
When a new Dataset in the Access Database

I want creat a Contact

But

When a exist Dataset, with updates in a field of this Dataset

I want Update this Contact





You now what i mean?

Sue Mosher said:
And i want, when its new then CREATE, ELSE i want edit the Contact Fields
You now what i mean?

No, your intent is unclear. When *what* is new?

--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers



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
 
Back
Top