I have written the following VB code to create a contact using the Exchange managed API. It creates a contact in the default "contacts" folder within the inbox. However I need to know how to modify it to save the contact into a public folder. If anyone knows how to do it in C# feel free to reply as I can translate back to VB.
Function create_contact()
ServicePointManager.ServerCertificateValidationCallback = New RemoteCertificateValidationCallback(AddressOf ValidateCertificate)
Dim service As New ExchangeService(requestedServerVersion:=ExchangeVersion.Exchange2007_SP1)
'Add a valid EWS service end point here or user Autodiscover
service.Url = New Uri("https://server/ews/exchange.asmx")
'Add a valid user credentials
service.Credentials = New WebCredentials("username", "password", "domain")
'To address the SSL challenge
ServicePointManager.ServerCertificateValidationCallback = New RemoteCertificateValidationCallback(AddressOf ValidateCertificate)
Try
Dim contact As Contact = New Contact(service)
contact.GivenName = "Brian"
contact.MiddleName = "David"
contact.Surname = "Johnson"
contact.FileAsMapping = FileAsMapping.SurnameCommaGivenName
contact.Save()
MsgBox("Contact created!!!")
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Function
You can specify the folder ID as a parameter for Save method of Contact class.
contact.Save(folderId)
Where folderId is an ID of your destionation public folder
See http://msdn.microsoft.com/en-us/library/dd635209(v=exchg.80).aspx for more information
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.