2012-09-28 46 views
0

你好,我想發送一個日曆邀請給其他成員,我怎麼能做到這一點在vb.net, 我添加了交流webreference,並可以發送一個正常的郵件給其他人。在VB.NET中使用EWS創建一個約會,我錯過了什麼?

這裏是我迄今爲止

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("[email protected]") 
     appointment.RequiredAttendees.Add("[email protected]") 
     appointment.OptionalAttendees.Add("[email protected]") 
     ' Save the appointment. 
     appointment.Save(SendInvitationsMode.SendToAllAndSaveCopy) 
    End Sub 

的Visual Studio告訴我說:

添加不 「的System.Array」

成員

「保存」不是會員的

「SendInvitationMode」 這個名字沒有聲明

我失去了什麼 「ExchangeServer.CalendarItemType」?

在此先感謝您的幫助

+0

關於.Add不是成員。您需要創建一個新的RequiredAttendee對象,並添加該對象,而不僅僅是您想要參加的電子郵件字符串,因爲這不起作用。 –

回答

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

相關問題