Home   |   Asp.Net 2.0   |   .Net Framework 2.0   |   IIS 6.0   |   Sql Server 2005   |   Visual Basic 2005   |   c# 2005   |   VS 2005   |   Visual Source Safe 2005

MS Dynamics CRM 3.0

SharePoint Portal Server 2003
SharePoint Server 2007
Dynamics NAV
Dynamics CRM
SharePoint Designer 2007
SharePoint Portal Server 2001
Windows SharePoint Services
Windows SharePoint Services 3.0
Project Server 2003
Project Server 2007
Dynamics – Point of Sale
Dynamics AX
Dynamics GP
Dynamics Retail Management System (RMS)
Dynamics SL
SQL Server 2000
Visual Basic .NET 2003
Visual C# .NET 2003
Visual C++ .NET 2003
Visual C++ 2005
Visual SourceSafe 6.0
Windows Server 2003
Windows Server 2003
Outlook 2003
ADO.NET 1.1
ASP.NET 1.0
Visual Studio Team Foundation Server
Visual Studio 2005 Team Edition
Windows Internet Explorer 7
BizTalk Server 2000
BizTalk Server 2002
BizTalk Server 2004
BizTalk Server 2006
Visual Studio 6.0
Access 2000
Access 2002
Access 2003
Access 2007
Access 97
Collaboration Data Objects 2.0
Commerce Server 2002
Content Management Server 2001
Commerce Server 2007
Content Management Server 2002
Data Access Components 2.7
Data Access Components 2.8
DirectX 9.0b
Office Small Business Accounting 2006
Accounting 2007
ActiveSync 4.1
Class Server 2.0
Groove 2007
Windows Vista
Outlook 2007
OneNote 2003
OneNote 2007
Office X for Mac
Zune software
Zune Live
Zoo Tycoon 2
Flight Simulator 2002
Dungeon Siege II

Cervo Technologies
The Right Source to Outsource

Oracle Database FAQS

Sharepoint Portal Server KB

Outlook 2007 Knowledge Base Articles

Collaboration Data Objects 2.0 Knowledge Base Articles

Describes how to use the CDOEX Library to create a contact in Visual C# .NET. Includes a code sample that you can use to create the contact.


This article describes how to use the Microsoft Collaboration Data Objects (CDO) for Exchange 2000 (CDOEX) Library to create a contact in Microsoft Visual C#.

MORE INFORMATION

To use the CDOEX Library to create a contact in Visual C# .NET or Visual C# 2005, 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 list, click Console Application.

By default, Class1.cs is created.

Note In Microsoft Visual Studio 2005, click Console Application in the Visual C# list. By default, Program.cs is created.
4.Add a reference to the CDOEX Library. To do so, follow these steps:
a. On the Project menu, click Add Reference.
b. 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.
c. In the Add References dialog box, click OK.
d. 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.Repeat step 4 to add a reference to the Microsoft ActiveX Data Objects 2.5 Library.
6.In the code window, replace the code with the following:
using System;

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

                        // TODO: Replace with your Contacts folder URL
			string sURL = "Http://<ExchServer>/Exchange/<UserAlias>/Contacts";
 			
			ADODB.Connection oCn = new ADODB.Connection();
			oCn.Provider = "exoledb.datasource";

			oCn.Open(sURL, "", "", 0);  
			if(oCn.State == 1)
			{
				Console.WriteLine("Connection Successful");
			}
			else
			{
				Console.WriteLine("Connection Failed");
				return;
			}			
			
			oPerson.Title = "Engineer";
			oPerson.FirstName = "First";
			oPerson.LastName = "Last";
			oPerson.Company = "CompanyName";
			oPerson.Email = "someone@example.com";
			
			oPerson.DataSource.SaveToContainer(sURL, null, 
				ADODB.ConnectModeEnum.adModeReadWrite, 
				ADODB.RecordCreateOptionsEnum.adCreateNonCollection, 
				ADODB.RecordOpenOptionsEnum.adOpenSource, 
				"", "");

			oCn.Close();

			oPerson = null;
			oCn = 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.Press F5 to build and to run the program.
9.Make sure that the contact is created in the specified folder.

REFERENCES

For more information, visit the following MSDN Web site:
http://msdn2.microsoft.com/en-us/exchange/default.aspx (http://msdn2.microsoft.com/en-us/exchange/default.aspx)
For additional information, click the following article number to view the article in the Microsoft Knowledge Base:


APPLIES TO
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
Microsoft Visual C# 2005

Keywords: 
kbcode kbmsg kbhowto KB310195

Copyright © 2004 - 2007 Gridview.org, Inc. All rights reserved. Powered by Smart Web Content Management System