0

您好,我想向其他成员发送日历邀请,我如何在 vb.net 中做到这一点,我添加了交换网络参考,并且可以向其他人发送普通邮件。

这是我到目前为止所拥有的

   Public Sub Einladungen()
        Dim esb As New ExchangeServer.ExchangeServiceBinding
        esb.Credentials = New NetworkCredential(Session("EX_UserName").ToString, Session("EX_Password").ToString)
        esb.Url = Session("EX_DomainURL")

        Dim appointment As CalendarItemType = New CalendarItemType

        ' Set properties on the appointment.
        appointment.Subject = "Dentist Appointment"
        appointment.Body = New BodyType
        appointment.Body.BodyType1 = BodyTypeType.Text
        appointment.Body.Value = "Agenda Items...."
        appointment.Start = New DateTime(2012, 3, 1, 9, 0, 0)
        appointment.End = appointment.Start.AddHours(2)

        appointment.Location = "Conf Room"
        appointment.RequiredAttendees.Add("user1@contoso.com")
        appointment.RequiredAttendees.Add("user2@contoso.com")
        appointment.OptionalAttendees.Add("user3@contoso.com")
        ' Save the appointment.
        appointment.Save(SendInvitationsMode.SendToAllAndSaveCopy)
    End Sub

Visual Studio 告诉我:

添加不是“System.Array”的成员

“保存”不是“ExchangeServer.CalendarItemType”的成员

未声明名称“SendInvitationMode”

我错过了什么?

在此先感谢您的帮助

4

1 回答 1

1

问题是您通过直接引用 Exchange Web 服务创建了自己的 EWS 代理类,但您找到的示例代码是使用Exchange Web Service Managed API构建的。

因此,您应该下载 EWS Managed API,添加对 Microsoft.Exchange.WebServices.dll 的引用,并将代码的开头更改为类似于以下内容:

Dim esb As New ExchangeService(ExchangeVersion.Exchange2007_SP1);
esb.Credentials = New NetworkCredential(Session("EX_UserName").ToString, Session("EX_Password").ToString)
esb.Url = Session("EX_DomainURL")

Dim appointment As new Appointment(esb);
// ... the rest of your code here.

您可能想看看这个例子: http: //msdn.microsoft.com/en-us/library/exchange/dd633661 (v=exchg.80).aspx

于 2012-10-03T12:10:39.010 回答