【问题标题】:Exchange ews managed api create item in public folderExchange ews managed api 在公用文件夹中创建项目
【发布时间】:2013-06-11 23:54:35
【问题描述】:

我编写了以下 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

【问题讨论】:

  • 这个问题你解决了吗?我也有同样的情况。

标签: c# vb.net exchange-server exchangewebservices


【解决方案1】:

您可以将文件夹ID指定为Contact类的Save方法的参数。

contact.Save(folderId)

其中 folderId 是您的目标公用文件夹的 ID

更多信息请参见http://msdn.microsoft.com/en-us/library/dd635209(v=exchg.80).aspx

【讨论】:

  • 如何获取公用文件夹的folderId
  • 您可以通过如下方式获取公共文件夹根目录的文件夹ID:var folderId = new FolderId(WellKnownFolderName.PublicFoldersRoot)。接下来,您可以使用 FindFolders 方法搜索所需的公共文件夹并从结果中获取文件夹 ID。
猜你喜欢
  • 1970-01-01
  • 2011-07-21
  • 1970-01-01
  • 2011-12-09
  • 2015-12-06
  • 2014-03-21
  • 2021-07-15
  • 2016-10-14
  • 1970-01-01
相关资源
最近更新 更多