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