title: Creating an appointment for lotus notes programmatically
body: <p>I need to create an appointment (Calendar entry) and distribute it to certain invitees automatically. </p>
  
  <p>I have two issues right now:</p>
  
  <p>1) The calendar entry does not appear on the calendar for the chair. I have worked around this by adding the chair as a required attendee which sends them a notice to confirm, however I would like to know how to add it automatically. </p>
  
  <p>2) The invitees are being sent an invitation, but they can not confirm it. Lotus throws an error saying that they cannot process the invitation because the even does not exist in their mail file. </p>
  
  <p>My code is in JAVA, but I can port to Lotusscript or Formula if need be. I just need to get it working. </p>
  
  <pre><code>import java.util.GregorianCalendar;
  
  import lotus.domino.AgentBase;
  import lotus.domino.Database;
  import lotus.domino.Document;
  import lotus.domino.Session;
  
  public class JavaAgent extends AgentBase {
  
      public void NotesMain() {
  
        try {
            Session s = getSession();
            Database db = s.getDatabase("server", "maildatabase.nsf", false);
            String user = s.getUserName();
  
            Document doc = db.createDocument();
            doc.replaceItemValue("Form", "Appointment");
            doc.replaceItemValue("AppointmentType", "3");
            doc.replaceItemValue("$PublicAccess", "1");
  
            doc.replaceItemValue("Subject", "New Meeting"); 
            doc.replaceItemValue("CALENDARDATETIME", s.createDateTime(new GregorianCalendar(2012, 7, 24, 9, 0)).getLocalTime());
            doc.replaceItemValue("Body", "an invitation");
  
            doc.replaceItemValue("StartDate", s.createDateTime("08/24/2012").getLocalTime());
            doc.replaceItemValue("EndDate", s.createDateTime("08/24/2012").getLocalTime());
            doc.replaceItemValue("StartTime", s.createDateTime("09:00:00 AM").getLocalTime());
            doc.replaceItemValue("EndTime", s.createDateTime("10:00:00 AM").getLocalTime());
            doc.replaceItemValue("StartDateTime", s.createDateTime(new GregorianCalendar(2012, 7, 24, 9, 0)));
            doc.replaceItemValue("EndDateTime", s.createDateTime(new GregorianCalendar(2012, 7, 24, 10, 0)));
  
            doc.replaceItemValue("RequiredAttendees", "Invitee/company");
            doc.appendItemValue("RequiredAttendees",user);
  
            doc.replaceItemValue("SendTo", "Invitee/company");
            doc.appendItemValue("SendTo",user);
            doc.replaceItemValue("EnterSendTo", "Invitee/company");
            doc.appendItemValue("EnterSendTo",user);
            doc.replaceItemValue("From", user);
            doc.replaceItemValue("Principal",user);
            doc.replaceItemValue("Chair", user); 
            doc.replaceItemValue("Location", "location test");
  
  
            doc.computeWithForm(true, false);
            doc.save(true,false,false);
  
            String sendTo = doc.getItemValueString("SendTo");
            doc.send(false, sendTo);
  
        } catch(Exception e) {
            System.out.print(e.getMessage());
         }
     }
  }
  </code></pre>
  
  <p>Any help is appreciated. Thanks.</p>