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 repeating meeting in Visual C#


View products that this article applies to.

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#.

↑ Back to the top


More information

To use the CDOEX Library to create a repeating meeting in Visual C#, follow these steps:
  1. Start Microsoft Visual Studio .NET or Microsoft Visual Studio 2005.
  2. On the File menu, point to New, and then click Project.
  3. 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.
  4. Add a reference to the Microsoft CDO for Exchange 2000 Library. To do this, 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.
      Note In Visual Studio 2005, you do not have to 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.
    Note CDOEX is supported only through a COM interop.
  5. 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.
  6. 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 = "http://ExchServer/Exchange/UserAlias/calendar";
    
    			ADODB.Connection oCn = new ADODB.Connection();
    			oCn.Provider = "exoledb.datasource";
    
    			oCn.Open(sURL, "", "", 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 = "zdu@dudomain.example.com";			
    			oFields.Update();
    
    			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 C#";
    			oApp.TextBody = "Hello...";
    
    			// Add Recurring
    			// Every Thursday starting Today and run 3 times
    			CDO.IRecurrencePatterns iRPatters = oApp.RecurrencePatterns;
    			CDO.IRecurrencePattern iRPatter = 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;
    
    			// Add Attendees
    			CDO.IAttendees iAtdees = oApp.Attendees;
    			CDO.IAttendee iAtdee = iAtdees.Add("User1@dudomain.example.com");  // 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, 
    				"", "");
    
    			oCn.Close();
    
    			oApp = null;
    			oCn = null;
    			oFields = null;
    			}
    			catch (Exception e)
    			{
    				Console.WriteLine("{0} Exception caught.", e);
    			}			
    		}
            }
    }
  7. Search for TODO in the code, and then modify the code for your environment.
  8. Build and then run the program.
  9. Make sure that the repeating meeting was created.

↑ Back to the top


References

For more information, click the following article number to view the article in the Microsoft Knowledge Base:
813349 Support policy for Microsoft Exchange APIs with .NET Framework applications

↑ Back to the top


Keywords: KB310557, kbhowto, kbcode, kbmsg

↑ Back to the top

Article Info
Article ID : 310557
Revision : 6
Created on : 11/29/2007
Published on : 11/29/2007
Exists online : False
Views : 399