General Development

C# Console App to Web App – mastallama

MastaLlama

Member

Posts: 671
From: Houston, TX USA
Registered: 08-10-2005
Hey everyone,

I've written a little program in C#.NET as a console application. I need to port to code over and use it in a .NET WebApp. I'm not even sure where to start! Basically, I'm connecting to Exchange and adding an appointment to someone's calendar. Simple enough but you won't be able to see the code function unless you have Exchange and run this code from the Exchange server (as it needs a ton of references).

Here's the code:


using System;

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

string sURL = "https://my.exchange.server/exchange/myUserName/Calendar/";

ADODB.Connection oCn = new ADODB.Connection();
oCn.Provider = "exoledb.datasource";

oCn.Open(sURL, "myUserName", "MyPassWord", 0);
if (oCn.State == 1)
{
Console.WriteLine("Good Connection");
}
else
{
Console.WriteLine("Bad Connection");
}

CDO.Configuration iConfg = new CDO.Configuration();
ADODB.Fields oFields;


oFields = iConfg.Fields;
oFields[CDO.CdoCalendar.cdoTimeZoneIDURN].Value = CDO.CdoTimeZoneId.cdoCentral;
oFields.Update();

oApp.Configuration = iConfg;
oApp.StartTime = Convert.ToDateTime("7/13/2007 5:30:00 PM");
oApp.EndTime = Convert.ToDateTime("7/13/2007 5:31:00 PM");
oApp.Location = "My Cube";
oApp.Subject = "Headin' out!";
oApp.TextBody = "Have a great weekend!";

// Specify Exceptions
CDO.IExceptions iExceps = oApp.Exceptions;
CDO.IException iExcep;

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

Any help would be greatly appreciated!

[This message has been edited by mastallama (edited July 18, 2007).]

MastaLlama

Member

Posts: 671
From: Houston, TX USA
Registered: 08-10-2005
As a Web App I want to add functionality to this by submitting the values of the appointment date, subject, etc... through a POST or GET.