Microsoft KB Archive/314367

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

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.</li> In the Add References dialog box, click OK.</li> If you are prompted to generate wrappers for the libraries that you selected, click Yes.</li></ol> </li> 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.</li>  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 = &quot;http://<ExchServer>/Exchange/<UserAlias>/calendar&quot;

Dim oCn As ADODB.Connection = New ADODB.Connection oCn.Provider = &quot;exoledb.datasource&quot;

oCn.Open(sURL, &quot;&quot;, &quot;&quot;, 0) If oCn.State = 1 Then Console.WriteLine(&quot;Good Connection&quot;) Else Console.WriteLine(&quot;Bad Connection&quot;) 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 = &quot;organizer@example.com&quot; oFields.Update

Dim oApp As CDO.Appointment = New CDO.Appointment oApp.Configuration = iConfg oApp.StartTime = Convert.ToDateTime(&quot;10/11/2001 10:00:00 AM&quot;) oApp.EndTime = Convert.ToDateTime(&quot;10/11/2001 11:00:00 AM&quot;) oApp.Location = &quot;My Cube&quot; oApp.Subject = &quot;Test: Create Meeting in VB.NET&quot; oApp.TextBody = &quot;Hello...&quot;

' 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(&quot;Add&quot;) 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(&quot;DELETE&quot;) iExcep.RecurrenceID = Convert.ToDateTime(&quot;10/11/2001 10:00:00 AM&quot;) ' Modify iExcep = oApp.Exceptions.Add(&quot;MODIFY&quot;) iExcep.RecurrenceID = Convert.ToDateTime(&quot;10/18/2001 10:00:00 AM&quot;) iExcep.StartTime = Convert.ToDateTime(&quot;10/17/2001 10:00:00 AM&quot;) iExcep.EndTime = Convert.ToDateTime(&quot;10/17/2001 1:00:00 pM&quot;)

' Add thee attendees. Dim iAtdees As CDO.IAttendees = oApp.Attendees Dim iAtdee As CDO.IAttendee = iAtdees.Add(&quot;User1@dudomain.example.com&quot;) ' TODO: 'iAtdee.Address = &quot;User1@dudomain.example.com&quot; ' 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, _         &quot;&quot;, &quot;&quot;)

oCn.Close

oApp = Nothing oCn = Nothing oFields = Nothing End Sub

End Module </li> Search for the TODO text string in the code, and then modify the code for your environment.</li> Press the F5 key to build and to run the program.</li> Make sure that the meeting was created.</li></ol>

Additional query words: VB.NET CDOEX

Keywords: kbxml kbhowtomaster KB314367

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.