Saving Contacts to the Exchange Store
Topic Last Modified: 2006-06-12
The Iperson.DataSource property returns the attached IDataSource interface. The IDataSource interface exposes four methods that save contacts to the Exchange store: Save, SaveTo, SaveToContainer, and SaveToObject.
After you bind the contact to a data source, you can call the IDataSource.Save method to save changes to the bound data source. You can call the IDataSource.SaveTo method to bind to, and save data to, an existing item specified by a URL. To bind to, and save data to, a new item specified by a URL, you can call the IDataSource.SaveToContainer method. The IDataSource.SaveToObject allows you to save data to a different object at run time.
Example
The following example illustrates how to create a contact and save it to a contact folder in the Exchange store.
Example
Visual Basic
'Declare variables
Dim iPer As New CDO.Person
Dim strURL As String
With iPer
'Set first and last names and company name
.FirstName = "Max"
.LastName = "Benson"
.Company = "Coho Winery"
'Indicate that this is a contact
.Fields("objectClass").Value = "contact"
'Save changes made to properties
.Fields.Update
End With
'Setup the URL for the users contact folder
strURL = "file://./backofficestorage/domain/mbx/User/Contacts/"
'Save the contact to the users contact folder
iPer.DataSource.SaveToContainer strURL