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);
}
}
}
} |