我编写了以下 VB 代码来使用 Exchange 托管 API 创建联系人。它会在收件箱的默认“联系人”文件夹中创建一个联系人。但是我需要知道如何修改它以将联系人保存到公用文件夹中。如果有人知道如何在 C# 中做到这一点,请随时回复,因为我可以翻译回 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