Article ID: 314367
Article Last Modified on 11/29/2007
APPLIES TO
- Microsoft Visual Basic .NET 2002 Standard Edition
- Microsoft Exchange 2000 Server Standard Edition
- Collaboration Data Objects for Exchange 2000
- Microsoft ActiveX Data Objects 2.5
This article was previously published under Q314367
Caution ADO and ADO MD have not been fully tested in a Microsoft .NET Framework environment. They may cause intermittent issues, especially in service-based applications or in multithreaded applications. The techniques that are discussed in this article should only be used as a temporary measure during migration to ADO.NET. You should only use these techniques after you have conducted complete testing to make sure that there are no compatibility issues. Any issues that are caused by using ADO or ADO MD in this manner are unsupported. For more information, see the following article in the Microsoft Knowledge Base:
840667 You receive unexpected errors when using ADO and ADO MD in a .NET Framework application
SUMMARY
This article describes how to use the Collaboration Data Objects (CDO) for Exchange 2000 (CDOEX) Library to create a recurring meeting that has exceptions in Microsoft Visual Basic .NET.
MORE INFORMATION
To use the CDOEX Library to create a recurring meeting in Visual Basic .NET, follow these steps.
Note To work correctly, run the sample code on a computer that is running Microsoft Exchange 2000 Server.
- Start Microsoft Visual Studio .NET.
- On the File menu, point to New, and then click Project.
- In the Visual Basic Projects types list, click Console Application.
By default, the Module1.vb file is created. - Add a reference to the CDOEX Library. To do so, follow these steps:
- On the Project menu, click Add Reference.
- Click the COM tab, locate Microsoft CDO for Exchange 2000 Library, and then click Select.
- In the Add References dialog box, click OK.
- If you are prompted to generate wrappers for the libraries that you selected, click Yes.
- Repeat step 4 to add a reference to the Microsoft ActiveX Data Objects 2.5 Library.
Note In step 4b, substitute Microsoft ActiveX Data Objects 2.5 Library for Microsoft CDO for Exchange 2000 Library. In the code window, replace the code with the following:
Module Module1 Sub Main() ' TODO: Replace with your folder URL Dim sURL As String sURL = "http://<ExchServer>/Exchange/<UserAlias>/calendar" Dim oCn As ADODB.Connection = New ADODB.Connection() oCn.Provider = "exoledb.datasource" oCn.Open(sURL, "", "", 0) If oCn.State = 1 Then Console.WriteLine("Good Connection") Else Console.WriteLine("Bad Connection") Return End If Dim iConfg As CDO.Configuration = New CDO.Configuration() Dim oFields As ADODB.Fields oFields = iConfg.Fields oFields.Item(CDO.CdoCalendar.cdoTimeZoneIDURN).Value = CDO.CdoTimeZoneId.cdoPacific ' TODO: Set Meeting Organizer oFields.Item(CDO.CdoConfiguration.cdoSendEmailAddress).Value = "organizer@example.com" oFields.Update() Dim oApp As CDO.Appointment = New CDO.Appointment() oApp.Configuration = iConfg oApp.StartTime = Convert.ToDateTime("10/11/2001 10:00:00 AM") oApp.EndTime = Convert.ToDateTime("10/11/2001 11:00:00 AM") oApp.Location = "My Cube" oApp.Subject = "Test: Create Meeting in VB.NET" oApp.TextBody = "Hello..." ' Add recurring appointment ' Every Thursday starting today, and repeat 3 times. Dim iRPatters As CDO.IRecurrencePatterns = oApp.RecurrencePatterns Dim iRPatter As CDO.IRecurrencePattern = iRPatters.Add("Add") iRPatter.Frequency = CDO.CdoFrequency.cdoWeekly iRPatter.Interval = 1 ' 1 hour from 10 to 11 iRPatter.DaysOfWeek.Add(4) ' every Thursday iRPatter.Instances = 3 ' Specify the exceptions. Dim iExceps As CDO.IExceptions = oApp.Exceptions Dim iExcep As CDO.IException ' Delete iExcep = oApp.Exceptions.Add("DELETE") iExcep.RecurrenceID = Convert.ToDateTime("10/11/2001 10:00:00 AM") ' Modify iExcep = oApp.Exceptions.Add("MODIFY") iExcep.RecurrenceID = Convert.ToDateTime("10/18/2001 10:00:00 AM") iExcep.StartTime = Convert.ToDateTime("10/17/2001 10:00:00 AM") iExcep.EndTime = Convert.ToDateTime("10/17/2001 1:00:00 pM") ' Add thee attendees. Dim iAtdees As CDO.IAttendees = oApp.Attendees Dim iAtdee As CDO.IAttendee = iAtdees.Add("User1@dudomain.example.com") ' TODO: 'iAtdee.Address = "User1@dudomain.example.com" ' TODO: Dim iCalMsg As CDO.ICalendarMessage = oApp.CreateRequest() iCalMsg.Message.Send() ' Save to the folder oApp.DataSource.SaveToContainer(sURL, , _ ADODB.ConnectModeEnum.adModeReadWrite, _ ADODB.RecordCreateOptionsEnum.adCreateNonCollection, _ ADODB.RecordOpenOptionsEnum.adOpenSource, _ "", "") oCn.Close() oApp = Nothing oCn = Nothing oFields = Nothing End Sub End Module
- Search for the TODO text string in the code, and then modify the code for your environment.
- Press the F5 key to build and to run the program.
- Make sure that the meeting was created.
Additional query words: VB.NET CDOEX
Keywords: kbxml kbhowtomaster KB314367