Moyosoft Products | Services | Download | Contact us    
Java Bridge to Exchange
import com.moyosoft.exchange.*;
import com.moyosoft.exchange.contact.*;
import com.moyosoft.exchange.folder.*;

public class CreateContact
{
  public static void main(String[] argsthrows ExchangeServiceException
  {
    // To provide hostname and credentials information, use:
    // Exchange exchange = new Exchange("hostname", "username", "password");
    Exchange exchange = ExchangeConnectionDialog.display();

    if(exchange == null)
    {
      return;
    }

    // Get the default Contacts folder
    ExchangeFolder folder = exchange.getContactsFolder();

    // Create a new contact in the folder
    ExchangeContact contact = folder.createContact();

    // Set the contact's first and last names
    contact.setFirstName("John");
    contact.setLastName("Smith");

    // Save the contact
    contact.save();

    // Display the ID and name of the new contact
    System.out.println("Created contact ID: " + contact.getItemId());
    System.out.println("Created contact name: " + contact.getDisplayName());
    
    // Delete the created contact
    contact.delete(false);
  }
}