Microsoft KB Archive/310557

= How to use the CDOEX library to create a repeating meeting in Visual C# =

Article ID: 310557

Article Last Modified on 11/29/2007

-

APPLIES TO


 * Microsoft Visual C# 2005
 * Microsoft Visual C# .NET 2003 Standard Edition
 * Microsoft Visual C# .NET 2002 Standard Edition
 * Microsoft ActiveX Data Objects 2.5
 * Microsoft ActiveX Data Objects 2.6
 * Microsoft ActiveX Data Objects 2.7
 * Collaboration Data Objects for Exchange 2000
 * Microsoft Exchange 2000 Server Standard Edition

-



This article was previously published under Q310557



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 Microsoft Collaboration Data Objects (CDO) for Exchange 2000 (CDOEX) Library to create a repeating meeting in Microsoft Visual C#.



MORE INFORMATION
To use the CDOEX Library to create a repeating meeting in Visual C#, follow these steps:  Start Microsoft Visual Studio .NET or Microsoft Visual Studio 2005. On the File menu, point to New, and then click Project. In the Visual C# Projectslist, click Console Application.

Note In Visual Studio 2005, select Visual C#.

By default, Class1.cs is created in Visual Studio .NET. Program.cs is created in Visual Studio 2005. Add a reference to the Microsoft CDO for Exchange 2000 Library. To do this, 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.

Note In Visual Studio 2005, you do not have to 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>

Note CDOEX is supported only through a COM interop.</li> If Visual Studio .NET or Visual Studio 2005 does not add a reference to the Microsoft ActiveX Data Objects 2.5 Library, repeat step 4 to add a reference to it.</li>  In the code window, replace the code with the following: using System;

namespace Samples {   class Class1 {       static void Main(string[] args) {           try {           CDO.Appointment oApp = new CDO.Appointment;

// TODO: string sURL = &quot;http://ExchServer/Exchange/UserAlias/calendar&quot;;

ADODB.Connection oCn = new ADODB.Connection; oCn.Provider = &quot;exoledb.datasource&quot;;

oCn.Open(sURL, &quot;&quot;, &quot;&quot;, 0); CDO.Configuration iConfg = new CDO.Configuration; ADODB.Fields oFields;

oFields = iConfg.Fields; oFields[CDO.CdoCalendar.cdoTimeZoneIDURN].Value = CDO.CdoTimeZoneId.cdoPacific;

// Set Meeting Organizer oFields[CDO.CdoConfiguration.cdoSendEmailAddress].Value = &quot;zdu@dudomain.example.com&quot;; oFields.Update;

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 C#&quot;; oApp.TextBody = &quot;Hello...&quot;;

// Add Recurring // Every Thursday starting Today and run 3 times CDO.IRecurrencePatterns iRPatters = oApp.RecurrencePatterns; CDO.IRecurrencePattern iRPatter = 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;

// Add Attendees CDO.IAttendees iAtdees = oApp.Attendees; CDO.IAttendee iAtdee = iAtdees.Add(&quot;User1@dudomain.example.com&quot;); // TODO: CDO.ICalendarMessage iCalMsg = (CDO.ICalendarMessage)oApp.CreateRequest; iCalMsg.Message.Send;

// Save to the Events Calendar oApp.DataSource.SaveToContainer(sURL, null,                ADODB.ConnectModeEnum.adModeReadWrite,                 ADODB.RecordCreateOptionsEnum.adCreateNonCollection,                 ADODB.RecordOpenOptionsEnum.adOpenSource,                 &quot;&quot;, &quot;&quot;);

oCn.Close;

oApp = null; oCn = null; oFields = null; }           catch (Exception e)            { Console.WriteLine(&quot;{0} Exception caught.&quot;, e); }                  }        } } </li> Search for TODO in the code, and then modify the code for your environment.</li> Build and then run the program.</li> Make sure that the repeating meeting was created.</li></ol>

<div class="references_section">