【问题标题】:Create an Appointment with EWS in VB.NET, what am i missing?在 VB.NET 中使用 EWS 创建约会,我缺少什么?
【发布时间】:2012-09-20 06:02:16
【问题描述】:

您好,我想向其他成员发送日历邀请,我如何在 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 告诉我:

Add 不是“System.Array”的成员

和

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

和

名称“SendInvitationMode”未声明

我错过了什么?

提前感谢您的帮助

【问题讨论】:

  • 关于.Add 不是会员。您将需要创建一个新的 RequiredAttendee 对象并添加它,而不仅仅是您要参加的电子邮件字符串,因为这不起作用。

标签: asp.net vb.net visual-studio-2008 exchangewebservices


【解决方案1】:

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

所以你应该做的是download the 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-05-30
    • 1970-01-01
    • 2020-05-11
    • 1970-01-01
    • 2011-01-26
    • 1970-01-01
    • 2019-06-09
    • 2011-06-01
    • 1970-01-01
    相关资源
    最近更新 更多