This example is a standalone application, not an applet. It is a complete program, including the importation declarations and the main() function. It demonstrates the basic framework of a Java program that accesses CDO Library objects. The main() function creates a Session object, logs on to it, and logs off, with minimal error checking.
import cdo.*;
import com.ms.com.*;
public class Sample0
{
public static void main(String args[])
{
// Create a messaging session (call the class factory).
_Session session = (_Session) new Session();
Variant v = new Variant();
Variant profileName = new Variant();
profileName.putString( "MyProfile" );
v.noParam();
// Log on.
try
{
session.Logon( profileName, v, v, v, v, v, v );
}
catch( Exception e )
{
System.out.println( "Logon failed!" );
}
// The logon was successful; now do desired processing.
// Now we will log off.
try
{
session.Logoff();
}
catch( Exception e )
{
System.out.println( "Logoff failed!" );
}
}
}