Solution : Sending Meeting Invite or Re-schedule using Lotus Script : Part 1 of 2

%remSolution:

How to Send Meeting Invite through Lotus Script:

How to Re-Schedule Meeting Invite through Lotus Script: (Will be covered in next topic)

Compatibility:Release 8.5.2. You can try on other versions too

Steps to send the first meeting invite:

  1. Create a Meeting Document in the sender’s mail-box or a mail in database, say, MeetingDoc

  2. Create a document to be sent to the recipients. We will call it as an OutBoxDoc

Part 2 : Sending Re-Schedule available @

http://www-10.lotus.com/ldd/nd8forum.nsf/DateAllThreadedWeb/4b53a89a07e4e8d385257c93002694a4?OpenDocument

%end rem

'Here is the code/agent:

'Declaration must be in Global

Dim session As NotesSession

    Dim MailDB As NotesDatabase



    Dim OutBoxDoc As NotesDocument

    Dim MeetingDoc As NotesDocument

    Dim StartDTObject As NotesDateTime

    Dim EndDTObject As NotesDateTime

    Dim StartDate$,StartTime$,EndDate$,EndTime$,StartDateTime$,EndDateTime$

    Dim UName$,Topic$,TimeZone$,Location$

    Dim Recipients

'///////////////////////////

Sub Initialize

    Set session=New NotesSession



    Call SetParameters

    Call CreateMeetingDoc

    Call CreateOutBoxDoc

End Sub

'///////////////////////////////

Sub SetParameters

    StartDate$="18-Apr-2014"

    StartTime$="09:00"



    EndDate$="18-Apr-2014"

    EndTime$="10:00"



    StartDateTime$=StartDate$+" "+StartTime$

    EndDateTime$=EndDate$+" "+EndTime$



    Set StartDTObject = New NotesDateTime(StartDateTime$)

    Set EndDTObject = New NotesDateTime(EndDateTime$)



    Topic$="Domino Solutions"

    UName$="SENDER NAME" ' Notes Name or any name whose mail box is on the server



'MailDatabasePath is where you want to create a meeting document

    Set MailDB=session.GetDatabase("ServerName","MailDatabasePath") ' associated with UName$



' comma separated names

    Recipients=Split("Lotus Notes Canonical or abbreviated format, xyz@abc.com, somename@gmail.com",",")

    

    Location$="New York"

End Sub

'/////////////////////////////////////

Sub CreateMeetingDoc

    Set MeetingDoc=MailDB.CreateDocument



    MeetingDoc.Form="Appointment" 'IMPORTANT

    MeetingDoc.Subject=Topic$

   

    Call MeetingDoc.ReplaceItemValue("StartDateTime",StartDTObject)

    Call MeetingDoc.ReplaceItemValue("CalendarDateTime",StartDTObject) 'IMPORTANT



    Set StartDTObject= New NotesDateTime(StartDateTime$)

    Call StartDTObject.SetAnyTime 'It will set only Date (not time)

    Call MeetingDoc.ReplaceItemValue("StartDate",StartDTObject)



    Set StartDTObject= New NotesDateTime(StartDateTime$)

    Call StartDTObject.SetAnyDate 'It will set only Time (not date

    Call MeetingDoc.ReplaceItemValue("StartTime",StartDTObject)



    Set EndDTObject= New NotesDateTime(EndDateTime$)

    Call MeetingDoc.ReplaceItemValue("EndDateTime",EndDTObject)



    Call EndDTObject.SetAnyTime 'It will set only Date (not time)

    Call MeetingDoc.ReplaceItemValue("EndDate",EndDTObject)



    Set EndDTObject= New NotesDateTime(EndDateTime$)

    Call EndDTObject.SetAnyDate 'It will set only Time (not date)

    Call MeetingDoc.ReplaceItemValue("EndTime",EndDTObject)

    

    Call MeetingDoc.ReplaceItemValue("$CSVersion","2") 'IMPORTANT



    Set EndDTObject= New NotesDateTime(EndDateTime$)

    Call MeetingDoc.ReplaceItemValue("$NoPurge",EndDTObject)'Common



    Call MeetingDoc.Replaceitemvalue("$PublicAccess","1") 'IMPORTANT



    Call MeetingDoc.Replaceitemvalue("AppointmentType","3") 'IMPORTANT

    Call MeetingDoc.Replaceitemvalue("ApptUNID",MeetingDoc.UniversalID) 'IMPORTANT



    Call MeetingDoc.Replaceitemvalue("Chair",UName$) 



    Call MeetingDoc.Replaceitemvalue("From",UName$)

    Call MeetingDoc.Replaceitemvalue("Location",Location$)

    Call MeetingDoc.Replaceitemvalue("MailOptions","0") 

    Call MeetingDoc.Replaceitemvalue("OriginalModTime",Now)

    Call MeetingDoc.Replaceitemvalue("Principal",UName$)

    Call MeetingDoc.Replaceitemvalue("Recipients",Recipients)

    Call MeetingDoc.Replaceitemvalue("RequiredAttendees",Recipients)

    Call MeetingDoc.ReplaceItemValue("SequenceNum",1) 'IMPORTANT

    Call MeetingDoc.ReplaceItemValue("UpdateSeq",1)

    Call MeetingDoc.Replaceitemvalue("_ViewIcon",133)

    Call MeetingDoc.Save(1,0)

End Sub

'///////////////////////////////

Sub CreateOutBoxDoc

    Set OutBoxDoc=MailDB.CreateDocument



    OutBoxDoc.Form="Notice" 'IMPORTANT

    OutBoxDoc.Subject="Invitation: "+Topic$+" "+"( "+StartDateTime$+" in " +Location$+")"

    OutBoxDoc.SendTo=Recipients

    OutBoxDoc.Topic=Topic$

   

    Set StartDTObject = New NotesDateTime(StartDateTime$)

    Set EndDTObject = New NotesDateTime(EndDateTime$)

    Call OutBoxDoc.ReplaceItemValue("StartDateTime",StartDTObject)



    Set StartDTObject= New NotesDateTime(StartDateTime$)

    Call StartDTObject.SetAnyTime 'It will set only Date (not time)

    Call OutBoxDoc.ReplaceItemValue("StartDate",StartDTObject)



    Set StartDTObject= New NotesDateTime(StartDateTime$)

    Call StartDTObject.SetAnyDate 'It will set only Time (not date

    Call OutBoxDoc.ReplaceItemValue("StartTime",StartDTObject)



    Set EndDTObject= New NotesDateTime(EndDateTime$)

    Call OutBoxDoc.ReplaceItemValue("EndDateTime",EndDTObject)



    Call EndDTObject.SetAnyTime 'It will set only Date (not time)

    Call OutBoxDoc.ReplaceItemValue("EndDate",EndDTObject)



    Set EndDTObject= New NotesDateTime(EndDateTime$)

    Call EndDTObject.SetAnyDate 'It will set only Time (not date)

    Call OutBoxDoc.ReplaceItemValue("EndTime",EndDTObject)



    Call OutBoxDoc.ReplaceItemValue("$CSVersion","2")    'IMPORTANT



    Set EndDTObject= New NotesDateTime(EndDateTime$)

    Call OutBoxDoc.ReplaceItemValue("$NoPurge",EndDTObject)



    Call OutBoxDoc.Replaceitemvalue("$PublicAccess","1") 'IMPORTANT







    Call OutBoxDoc.Replaceitemvalue("AppointmentType","3") 'IMPORTANT

    Call OutBoxDoc.Replaceitemvalue("ApptUNID",MeetingDoc.UniversalID) 'IMPORTANT

    Call OutBoxDoc.Replaceitemvalue("Chair",UName$)

    Call OutBoxDoc.Replaceitemvalue("From",UName$)

    Call OutBoxDoc.Replaceitemvalue("Location",Location$)



    Call OutBoxDoc.Replaceitemvalue("NoticeType","I") 'IMPORTANT



    Call OutBoxDoc.Replaceitemvalue("OriginalModTime",Now)'Modification Time



    Call OutBoxDoc.Replaceitemvalue("Principal",UName$)

    Call OutBoxDoc.Replaceitemvalue("Recipients",Recipients)

    Call OutBoxDoc.Replaceitemvalue("RequiredAttendees",Recipients)

    Call OutBoxDoc.ReplaceItemValue("SendTo",Recipients)

    Call OutBoxDoc.Replaceitemvalue("SequenceNum",1) 'IMPORTANT

    Call OutBoxDoc.ReplaceItemValue("UpdateSeq",1)

    Call OutBoxDoc.ReplaceItemValue("WebDateTimeInit","1")

    Call OutBoxDoc.Replaceitemvalue("_ViewIcon",133)

    OutBoxDoc.UniversalID=MeetingDoc.UniversalID 'VERY VERY IMPORTANT



    Call OutBoxDoc.Send(0)

End Sub

Subject: Some comments

Nice work. It should be noted that your code is only designed to handle non-repeating cases. Adding repeating to the mix requires additional work.

Your CreateMeetingDoc routine needs to have this line:

    Call MeetingDoc.Replaceitemvalue("$BusyName",UName$) 

if you want the new entry to show up in busytime for the user.

You also do not have any handling of timezones so the results will not be consistent across different users running it in different time zones.

If you do not want to get into that hairball then you should add:

    Call MeetingDoc.Replaceitemvalue("NoTZInfo","1") 

and

    Call OutBoxDoc.Replaceitemvalue("NoTZInfo","1") 

when you do not know the proper starting / ending time zone info to use.

Im not an expert on LotusScript but I think:

    Call OutBoxDoc.Replaceitemvalue("ApptUNID",MeetingDoc.UniversalID) 'IMPORTANT

will not set the ApptUNID value to the string value of the meeting entries UNID. You want ApptUNID to be the string value of it, not an actual numeric value. If this does give the string value (e.g. type Text) then great. Otherwise this needs a little fixing.

Bruce

IBM