Creating an appointment for lotus notes programmat

2019-05-10 01:19发布

问题:

I need to create an appointment (Calendar entry) and distribute it to certain invitees automatically.

I have two issues right now:

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.

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.

My code is in JAVA, but I can port to Lotusscript or Formula if need be. I just need to get it working.

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());
       }
   }
}

Any help is appreciated. Thanks.

回答1:

I think it would interesting to find out if it is possible to send all the attendees an iCalendar file. There are several examples on the net, here are some: - send appointment invitation to lotus notes 8.5 clients via c# - http://www.dominoguru.com/pages/icalendar_domino-outlook.html



回答2:

I ended up doing this. It forces the user to set the dates and send the invitations manually, but its the closest I could get. I could not use the iCal attachment because I need everyone to be part fo the same event for rescheduling purposes.

    @Command([Compose];"" : "mailfile.nsf";"Calendar Entry");
    @PostedCommand([EditGotoField];"Subject");
    @PostedCommand( [EditInsertText]; "Title" );
    @PostedCommand([EditGotoField];"EnterSendTo");
    @PostedCommand([EditInsertText]; "Bob Test");
    @PostedCommand([EditGotoField];"Location");
    @PostedCommand([EditInsertText]; "Location" );
    @PostedCommand([EditGotoField];"StartTime");
    @PostedCommand([EditInsertText]; @Text(@Time(9;0;0)));
    @PostedCommand([EditGotoField];"Body");
    @PostedCommand([EditInsertText];@UpperCase("Set Start and End Dates to: " + @Text(@Adjust(BidDay;0;0;-1;0;0;0))));