Go Back   SitePoint Forums > Forum Index > Program Your Site > .NET
Newsletter FAQ Members List Calendar Mark Forums Read

New to SitePoint Forums? Register here for free!

SitePoint Sponsor
 
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old Jul 12, 2004, 14:03   #1
jerryc
SitePoint Member
 
Join Date: Jul 2004
Location: Seattle
Posts: 2
Sending Outlook Appointments to a Different Server

Hi.

I'm trying to programmatically send Outlook Meeting announcements to e-mail accounts that use Outlook, but may be on another Exchange server (or, in my case, I am actually on a POP3 server). Is there a way to do this?

This is the CDO code that I'm trying to use, but I do not find a complete example:

class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
CDO.PersonClass person = new CDO.PersonClass();
String strURL = "mailto:jerryc@vioma.com";
person.Email = "jerryc@vioma.com";

// person.DataSource.Open(strURL,null,0,0,0,"jerryc","");
CDO.IMailbox mailbox = (CDO.IMailbox) person.GetInterface("IMailbox");
CDO.Appointment appt = CreateAppointment(new DateTime(2004,7,15),new
DateTime(2004,7,15),"subject","location","agenda",mailbox);
String[] mandatory = {"jerryc@vioma.com"};
SendMeetingRequest(appt, mailbox, person, mandatory,mandatory);
// Console.WriteLine("URL to inbox for " + strURL + " is: " + mailbox.Inbox);
Console.ReadLine();

}
static CDO.Appointment CreateAppointment(DateTime StartTime,
DateTime EndTime,
String Subject,
String Location,
String TextBody,
CDO.IMailbox iMbx)
{
try
{
// Variables.
CDO.Appointment iAppt = new CDO.Appointment();
// ADODB.Connection Conn = new ADODB.Connection();
// Conn.Provider = "ExOLEDB.DataSource";

//Set the appointment properties.
iAppt.StartTime = StartTime;
iAppt.EndTime = EndTime;
iAppt.Subject = Subject;
iAppt.Location = Location;
iAppt.TextBody = TextBody;

//Save the appointment
/* Conn.Open(iMbx.BaseFolder, "", "", -1);
iAppt.DataSource.SaveToContainer(iMbx.Calendar, Conn,
ADODB.ConnectModeEnum.adModeReadWrite,
ADODB.RecordCreateOptionsEnum.adCreateNonCollection,
ADODB.RecordOpenOptionsEnum.adOpenSource, "", "");

Console.WriteLine("Appointment saved."); */
return iAppt;
}
catch (Exception err)
{
Console.WriteLine(err.ToString());
return null;
}
}

// Reference to Microsoft ActiveX Data Objects 2.5 Library
// Reference to Microsoft CDO for Exchange 2000 Library
// Reference to Active DS Type Library

// Note: It is recommended that all input parameters be validated when they are
// first obtained from the user or user interface.
static void SendMeetingRequest(CDO.Appointment iAppt, CDO.IMailbox iMbx, CDO.Person iPers,
string[] strAttnMandatory, string[] strAttnOptional)
{
try
{
// Variables.
CDO.CalendarMessage iCalMsg;
CDO.Configuration Config = new CDO.Configuration();
CDO.Attendee iAttendee = new CDO.Attendee();
//CDO.Person iPers = new CDO.Person();

// Set the configuration fields.
//iPers = (CDO.Person)iMbx;
Config.Fields[CDO.CdoConfiguration.cdoSendEmailAddress].Value = iPers.Email;
//Config.Fields[CDO.CdoConfiguration.cdoMailboxURL].Value = iMbx.BaseFolder;
Config.Fields.Update();

iAppt.Configuration = Config;

// Add required attendee(s).
long I;
for (I = 0; I < strAttnMandatory.Length; ++I)
{
Console.WriteLine("Mandatory Attendee E-Mail:" + strAttnMandatory[i]);
iAttendee = iAppt.Attendees.Add("");
iAttendee.Address = Convert.ToString(strAttnMandatory[i]);
iAttendee.Role = CDO.CdoAttendeeRoleValues.cdoRequiredParticipant;
}

// Add optional attendee(s).
for (I = 0; I < strAttnOptional.Length; ++I)
{
Console.WriteLine("Optional Attendee E-Mail:" + strAttnOptional[i]);
iAttendee = iAppt.Attendees.Add("");
iAttendee.Address = Convert.ToString(strAttnOptional[i]);
iAttendee.Role = CDO.CdoAttendeeRoleValues.cdoOptionalParticipant;
}

// Create the calendar message.
iCalMsg = iAppt.CreateRequest();

// Save these changes to the appointment.
// iAppt.DataSource.Save();

// Send the calendar message.
iCalMsg.Message.Send();

Console.WriteLine("Meeting request sent.");
}
catch (Exception err)
{
Console.WriteLine(err.ToString());
}
}

}
}
jerryc is offline   Reply With Quote
 

Bookmarks

« Previous Thread | Next Thread »

Thread Tools
Display Modes

 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Sponsored Links
 
Forum Jump


All times are GMT -7. The time now is 16:41.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright 1998-2009, SitePoint Pty Ltd. All Rights Reserved