Export (0) Print
Expand All

Sending a Meeting Request

Exchange Server 2003

Sending a Meeting Request

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

A meeting request is a message sent by the meeting organizer to invite other users to a meeting. A meeting request contains a description of the meeting, including the start time, end time, and location. Collaboration Data Objects (CDO) creates a meeting request from an Appointment object by using the IAppointment.CreateRequest method.

To send a meeting request
  1. Create or open an Appointment object.
  2. Add attendees to the meeting by adding Attendee objects to the Appointment's Attendees collection.
  3. Save the Appointment to the organizer's calendar (optional).
  4. Create a CalendarMessage object using the IAppointment.CreateRequest method.
  5. Send the message requesting that the users attend the meeting.
Note  By default, calendar messages are sent by using the SMTP pick-up directory.

This topic contains Microsoft® Visual Basic®, Microsoft Visual C++®, Microsoft C#, and Visual Basic .NET code examples.

Visual Basic

The following example shows how to add attendees to an appointment and send a meeting request to the specified users.

' Reference to Microsoft ActiveX Data Objects 2.5 Library
' Reference to Microsoft CDO for Exchange 2000 Library

' Note: It is recommended that all input parameters be validated when they are
' first obtained from the user or user interface.
Sub SendMeetingRequest(iAppt As CDO.Appointment, _
                        iMbx As IMailbox, _
                        strAttnMandatory() As String, _
                        strAttnOptional() As String)

    Dim iCalMsg     As CalendarMessage
    Dim Config      As New Configuration
    Dim iAttendee   As New Attendee
    Dim iPers       As CDO.Person

    'Set the configuration fields
    Set iPers = iMbx
    Config(cdoSendEmailAddress) = iPers.Email
    Config(cdoMailboxURL) = iMbx.BaseFolder
    Config.Fields.Update

    With iAppt
        .Configuration = Config

        'Add attendees
        Dim I As Long
        For I = LBound(strAttnMandatory) To UBound(strAttnMandatory)
            Debug.Print "Mandatory Attendee E-Mail:" & strAttnMandatory(I)
            Set iAttendee = .Attendees.Add
            iAttendee.Address = CStr(strAttnMandatory(I))
            iAttendee.Role = cdoRequiredParticipant
        Next I

        For I = LBound(strAttnOptional) To UBound(strAttnOptional)
            Debug.Print "Optional Attendee E-Mail:" & strAttnOptional(I)
            Set iAttendee = .Attendees.Add
            iAttendee.Address = CStr(strAttnOptional(I))
            iAttendee.Role = cdoOptionalParticipant
        Next I

        'Create the calendar message and send it
        Set iCalMsg = .CreateRequest

        'Save these changes to the appointment
        .DataSource.Save

        iCalMsg.Message.Send
    End With

End Sub

C++

The following example shows how to add attendees to an appointment and send a meeting request to the specified users.

/*
 Assume that the following paths are in your
 INCLUDE path.
 %CommonProgramFiles%\system\ado
 %CommonProgramFiles%\microsoft shared\cdo
*/

#import <msado15.dll> no_namespace
#import <cdoex.dll> no_namespace
#include <iostream.h>
#include <vector>
using namespace std;

// Note: It is recommended that all input parameters be validated when they are
// first obtained from the user or user interface.
void sendMeetingRequest(
                  IAppointmentPtr& iAppt,
                  IMailboxPtr& iMbx,
                  vector<bstr_t>& AttnMand,
                  vector<bstr_t>& AttnOpt
                  ) {

   ICalendarMessagePtr iCalMsg(__uuidof(CalendarMessage));
   IConfigurationPtr   iConf(__uuidof(Configuration));
   IAttendeePtr        iAttn;
   IPersonPtr          iPer;

   try {
      iPer = iMbx;
   }
   catch(_com_error e ) {
      cerr << "Invalid or unbound Person object reference passed. " << endl;
      _com_issue_error(E_INVALIDARG);
   }

   iConf->Fields->Item[cdoSendEmailAddress]->Value = variant_t(iPer->Email);
   iConf->Fields->Item[cdoMailboxURL]->Value = variant_t(iMbx->BaseFolder);
   iConf->Fields->Update();

   iAppt->Configuration = iConf;

   typedef vector<bstr_t>::const_iterator CI;
   for(CI p = AttnMand.begin(); p != AttnMand.end(); p++) {
      iAttn = iAppt->Attendees->Add(bstr_t());
      iAttn->Address = _bstr_t(*p);
      iAttn->Role = cdoRequiredParticipant;
      cout << "Added " << bstr_t(*p) << " as required attendee to meeting" << endl;
   }

   for(p = AttnOpt.begin(); p != AttnOpt.end(); p++) {
      iAttn = iAppt->Attendees->Add(bstr_t());
      iAttn->Address = _bstr_t(*p);
      iAttn->Role = cdoOptionalParticipant;
      cout << "Added " << bstr_t(*p) << " as optional attendee to meeting" << endl;
   }


   try {
      iCalMsg = iAppt->CreateRequest();
      iCalMsg->Message->Send();
   }
   catch(_com_error e) {
      cerr << "Error creating and sending request" << endl;
      throw e;
   }

   try {
      iAppt->DataSource->Save();
   }
   catch(_com_error e) {
      cerr <<  "Error saving appointment!" << endl;
      throw e;
   }

}

C#

The following example shows how to add attendees to an appointment and send a meeting request to the specified users.

// 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,
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() - 1) ; ++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() - 1); ++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());
   }
} 

Visual Basic .NET

The following example shows how to add attendees to an appointment and send a meeting request to the specified users.

' 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.
Sub SendMeetingRequest(ByVal iAppt As CDO.Appointment, _
                       ByVal iMbx As CDO.IMailbox, _
                       ByVal strAttnMandatory() As Object, _
                       ByVal strAttnOptional() As Object)
   Try
      ' Variables.
      Dim iCalMsg As CDO.CalendarMessage
      Dim Config As New CDO.Configuration()
      Dim iAttendee As New CDO.Attendee()
      Dim iPers As CDO.Person

      ' Set the configuration fields.
      iPers = iMbx
      Config(CDO.CdoConfiguration.cdoSendEmailAddress).Value = iPers.Email
      Config(CDO.CdoConfiguration.cdoMailboxURL).Value = iMbx.BaseFolder
      Config.Fields.Update()

      With iAppt
         .Configuration = Config

         ' Add required attendee(s).
         Dim I As Long
         For I = LBound(strAttnMandatory) To UBound(strAttnMandatory)
            Console.WriteLine("Mandatory Attendee E-Mail:" & strAttnMandatory(I))
            iAttendee = .Attendees.Add
            iAttendee.Address = CStr(strAttnMandatory(I))
            iAttendee.Role = CDO.CdoAttendeeRoleValues.cdoRequiredParticipant
         Next I

         ' Add optional attendee(s).
         For I = LBound(strAttnOptional) To UBound(strAttnOptional)
            Console.WriteLine("Optional Attendee E-Mail:" & strAttnOptional(I))
            iAttendee = .Attendees.Add
            iAttendee.Address = CStr(strAttnOptional(I))
            iAttendee.Role = CDO.CdoAttendeeRoleValues.cdoOptionalParticipant
         Next I

         ' Create the calendar message.
         iCalMsg = .CreateRequest

         ' Save these changes to the appointment.
         .DataSource.Save()

         ' Send the meeting request.
         iCalMsg.Message.Send()

         Console.WriteLine("Meeting request sent.")

      End With

      Catch err As Exception
         Console.WriteLine(err.ToString())
      End Try
End Sub
 
Show:
© 2014 Microsoft