Calendar Items

  1. Creating and Sending a Meeting Request

  2. Creating an Appointment

  3. Checking User's Availability

  4. Searching for an Appointment Item

Make sure you have completed all the configuration requirements before running any of the examples.

1. Creating and Sending a Meeting Request

import com.linar.jintegra.Cleaner;
import com.intrinsyc.cdo.*;
import java.util.Date;

public class SendMeetingRequest {

    public static void main(String[] args) {

        //TODO: Change the following parameters based on your setup and configuration
        // the logon parameters of the service account you used to configure CDO
        String domain           = "mydomain";
        String username         = "jsmith";
        String password         = "password";

        // the DNS name or IP address of the machine where you installed CDO
        String CDOmachine       = "0.0.0.0";

        // the DNS name or IP address of the Exchange Server
        String exchangeServer   = "0.0.0.0";

        // the mailbox you wish to access (NOTE: this is the same as the user's login name
        // e.g., if the username is jsmith, mailbox would also be jsmith )
        String mailbox          = "jsmith";

        // e-mail address of recipients
        String recipient1    = "test@intrinsyc.com";
        String recipient2    = "jsmith@jintegra.com";

        try {
            // authenticate to Windows
            com.linar.jintegra.AuthInfo.setDefault(domain, username, password);

            // create a Session in the CDOmachine
            Session session = new Session(CDOmachine);

            // logon to the Exchange Server
            session.logon(null, null, new Boolean(false), new Boolean(true),
                          new Boolean(false), new Boolean(false),
                          exchangeServer + "\n" + mailbox);

            // retrieve appointments collection from the Calendar
            Integer defaultCalendar = new Integer(CdoDefaultFolderTypes.CdoDefaultFolderCalendar);
            Folder calendar = new FolderProxy(session.getDefaultFolder(defaultCalendar));
            Messages appointments = new MessagesProxy(calendar.getMessages());

            // add a new appointment to the collection
            AppointmentItem appointment = new AppointmentItemProxy(appointments.add(null, null, null, null));

            // set appointment details
            appointment.setSubject("J-Integra for Exchange Evaluation");
            appointment.setLocation("Meeting Room - 10th Floor");
            appointment.setStartTime( new Date());  // appointment starts now
            appointment.setText("Discuss viability of J-Integra");

            // Set appointment recipients
            Recipients recipients = new RecipientsProxy(appointment.getRecipients());
            Recipient r1 = new RecipientProxy(recipients.add(null, null, null, null));
            Recipient r2 = new RecipientProxy(recipients.add(null, null, null, null));
            r1.setName(recipient1);
            r2.setName(recipient2);

            // r1 will be the 'to' address and r2 will be 'cc'-ied
            r1.setType(new Integer(CdoRecipientType.CdoTo));
            r2.setType(new Integer(CdoRecipientType.CdoCc));

            // Each recipient added must be resolved before it can be used.
            // 0 == false to inhibit dialog boxes from popping up
            r1.resolve(new Integer(0));
            r2.resolve(new Integer(0));

            // set meeting status type to CdoMeeting
            appointment.setMeetingStatus(new Integer(CdoMeetingStatusTypes.CdoMeeting));

            // send the appointment
            appointment.send(null, null, null);

            System.out.println("Meeting request has been sent to: \n \t" + recipient1 + "\n \t" + recipient2 );

            // logoff from the session
            session.logoff();
        } catch (Exception ex) {
            ex.printStackTrace();
        }finally{
            // release all COM references
            Cleaner.releaseAll();
        }
    }
}

2. Creating an Appointment

Creating an appointment is like creating a meeting request as shown in the preceding example but instead of sending the appointment to a list of recipients, you simply save the appointment in the Calendar by calling the update() method of the Appointment object.

// TODO: create and logon to a Session

// retrieve appointments collection from the Calendar
Integer defaultCalendar = new Integer(CdoDefaultFolderTypes.CdoDefaultFolderCalendar);
Folder calendar = new FolderProxy(session.getDefaultFolder(defaultCalendar));
Messages appointments = new MessagesProxy(calendar.getMessages());

// add a new appointment to the collection
AppointmentItem appointment = new AppointmentItemProxy(appointments.add(null, null, null, null));

// set appointment details
appointment.setSubject("J-Integra for Exchange Evaluation");
appointment.setLocation("Meeting Room - 10th Floor");
appointment.setStartTime( new Date());  // appointment starts now
appointment.setText("Discuss viability of J-Integra");

// save appointment item in the Calendar
appointment.update(new Boolean(true), new Boolean(true));

3. Checking User's Availability

CDO provides functionality to check the availability (free/tentative/busy/out-of-office information) of a user. You do not need special access permissions to view this information. For more details, refer to this knowledge base article.

4. Searching for an Appointment Item

Refer to this knowledge base article for an example on how to search for an appointment item.