How to create an Outlook Calendar folder on a computer that is running Exchange 2000 Server by using Visual C# (310279)



The information in this article applies to:

  • Microsoft Visual C# 2005
  • Microsoft Visual C# .NET (2003)
  • Microsoft Visual C# .NET (2002)
  • Microsoft Exchange 2000 Server
  • Microsoft XML 3.0

This article was previously published under Q310279

SUMMARY

This article describes how to use Microsoft XML 3.0 to create a Microsoft Outlook Calendar folder on a computer that is running Microsoft Exchange 2000 Server by using Microsoft Visual C# .

MORE INFORMATION

To use Microsoft XML 3.0 to create an Outlook Calendar folder, 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# Projects types list, click Console Application.

    In Visual Studio .NET, Class1.cs is created by default. In Visual Studio 2005, Program.cs is created by default.

    Note In Visual Studio 2005, click Visual C#, and then click Console Application.
  4. Add a reference to Microsoft XML 3.0. To do so, follow these steps:
    1. On the Project menu, click Add Reference.
    2. Click the COM tab, locate Microsoft XML v3.0, 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.
  5. In the code window, replace the code with the following:
    using System;
    
    namespace WebDav
    {
    	class Class1
    	{	
    		public static void Main(String [] args)
    		{
    			try 
    			{			
    			MSXML2.XMLHTTP30 oXMLHttp = new MSXML2.XMLHTTP30();
    			
                            // TODO: Replace with your new folder URL
    			String sUrl = "http://ExchServer/public/MyApplication/NewFolder";
    			// TODO: Replace the account and password			
    			oXMLHttp.open("MKCOL", sUrl, false, @"UserDomain\UserAlias", "UserPassword"); 
    
    			String sQuery;
    
    			sQuery = "<?xml version='1.0'?>" + 
    				"<a:propertyupdate xmlns:a='DAV:' " + 
    				"xmlns:ex='http://schemas.microsoft.com/exchange/'>" + 
    				"<a:set><a:prop>" + 
    				"<ex:outlookfolderclass>IPF.Appointment</ex:outlookfolderclass>" + 
    				"</a:prop></a:set>" + 
    				"</a:propertyupdate>";
    
    			oXMLHttp.setRequestHeader("Content-Type", "text/xml");				
    			Console.WriteLine(sQuery.Length);
    			oXMLHttp.send(sQuery);
    
    			Console.WriteLine(oXMLHttp.status);
    			Console.WriteLine(oXMLHttp.statusText);
    			Console.WriteLine(oXMLHttp.responseText);
    			}
    			catch (Exception e)
    			{
    				Console.WriteLine("{0} Exception caught.", e);
    			}
    
    		}
             }
    }
    					
  6. Search for TODO in the code, and then modify the code for your environment.
  7. Press F5 to build and to run the program.
  8. Make sure that the folder was created.

Modification Type:MinorLast Reviewed:10/4/2006
Keywords:kbMsg kbcode kbXML kbHOWTOmaster KB310279 kbAudDeveloper