Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

How to use the CDOEX Library to create a recurring meeting that has exceptions in Visual Basic .NET


View products that this article applies to.

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 (http://support.microsoft.com/kb/840667/ ) You receive unexpected errors when using ADO and ADO MD in a .NET Framework application

↑ Back to the top


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.

↑ Back to the top


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.
  1. Start Microsoft Visual Studio .NET.
  2. On the File menu, point to New, and then click Project.
  3. In the Visual Basic Projects types list, click Console Application.

    By default, the Module1.vb file is created.
  4. Add a reference to the CDOEX Library. To do so, follow these steps:
    1. On the Project menu, click Add Reference.
    2. Click the COM tab, locate Microsoft CDO for Exchange 2000 Library, and then click Select.
    3. In the Add References dialog box, click OK.
    4. If you are prompted to generate wrappers for the libraries that you selected, click Yes.
  5. 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.
  6. 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
    					
  7. Search for the TODO text string in the code, and then modify the code for your environment.
  8. Press the F5 key to build and to run the program.
  9. Make sure that the meeting was created.

↑ Back to the top


Keywords: KB314367, kbhowtomaster, kbxml

↑ Back to the top

Article Info
Article ID : 314367
Revision : 4
Created on : 11/29/2007
Published on : 11/29/2007
Exists online : False
Views : 377