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

%REM Sending Meeting Invite or Re-schedule using Lotus Script : Part 2 of 2

Part 2:

Sending Re-Schedule

Part 1 available @

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

%END REM

'All the variables in Global

Dim session As NotesSession

    Dim MailDB As NotesDatabase

    Dim currdb As NotesDatabase

    Dim dc As NotesDocumentCollection

    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$,SeqNum%

    Dim Recipients

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

Sub Initialize

    Set session=New NotesSession

’ Must be same server and db path where the original invite was created

Set MailDB=session.GetDatabase(“ServerName”,“MailDatabasePath”)

    Call SetParameters

    Call CreateMeetingDoc



    Call SetParameters

    Call CreateOutBoxDoc

End Sub

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

Sub SetParameters

    StartDate$="21-Apr-2014"

    StartTime$="11:00"



    EndDate$="21-Apr-2014"

    EndTime$="12:00"



    StartDateTime$=StartDate$+" "+StartTime$

    EndDateTime$=EndDate$+" "+EndTime$



    Set StartDTObject = New NotesDateTime(StartDateTime$)

    Set EndDTObject = New NotesDateTime(EndDateTime$)



    Topic$="Domino Solutions : Updated Version"

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





'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.GetDocumentByUNID("STRINGFORMAT OF THE ORIGINAL/FIRST MEETING DOCUMENT UNID")



    MeetingDoc.Form="Appointment" 'IMPORTANT

    MeetingDoc.Subject=Topic$        



    Call MeetingDoc.ReplaceItemValue("StartDateTime",StartDTObject)

Call MeetingDoc.ReplaceItemValue("CalendarDateTime",StartDTObject)



    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)

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



    Set EndDTObject= New NotesDateTime(EndDateTime$)

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



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

    Call MeetingDoc.RemoveItem("NoticeType")



'FOLLOWING TWO LINES ARE VERY VERY IMPORTANT

'***************************

    SeqNum%=MeetingDoc.GetItemValue("SequenceNum")(0) 'VERY VERY IMPORTANT

    Call MeetingDoc.Replaceitemvalue("SequenceNum",SeqNum%+1) 'VERY VERY IMPORTANT

'***************************





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

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



    Call MeetingDoc.Replaceitemvalue("_ViewIcon",158) 'REQUIRED TO DISPLAY APPROPRIATE ICON

    Call MeetingDoc.Replaceitemvalue("Recipients",Recipients)

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

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

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

    Call MeetingDoc.Replaceitemvalue("ApptUNID",MeetingDoc.UniversalID) 'THIS ENSURES THAT THE APPUNID HAS NOT CHANGED

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

    Call MeetingDoc.Replaceitemvalue("RequiredAttendees",Recipients)



    Call MeetingDoc.Save(1,0)

End Sub

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

Sub CreateOutBoxDoc

    Set OutBoxDoc=MailDB.CreateDocument



    OutBoxDoc.Form="Notice"

    OutBoxDoc.Subject="Rescheduled: "+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)



'THE "CalendarDateTime" FIELD NOT REQUIRED WHILE MAILING

    ' NOT REQUIRED Call OutBoxDoc.ReplaceItemValue("CalendarDateTime",StartDTObject)



    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("$CSFlags","w") 'IMPORTANT





    Set EndDTObject= New NotesDateTime(EndDateTime$)

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

    Call OutBoxDoc.MakeResponse(MeetingDoc)

    Call OutBoxDoc.ReplaceItemValue("$REFOptions","1")



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

    Call OutBoxDoc.Replaceitemvalue("NoticeType","U")  'IMPORTANT-INDICATES RE-SCHEDULE

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

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

    Call OutBoxDoc.Replaceitemvalue("SequenceNum",MeetingDoc.SequenceNum(0)) 'VERY VERY IMPORTANT

    Call OutBoxDoc.Replaceitemvalue("_ViewIcon",33) 'APPROPRIATE ICON

    Call OutBoxDoc.Replaceitemvalue("Recipients",Recipients)

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

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

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

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

    Call OutBoxDoc.Replaceitemvalue("RequiredAttendees",Recipients)

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

   

    Call OutBoxDoc.Replaceitemvalue("UpdateSeq",1)

    Call OutBoxDoc.Replaceitemvalue("PostedDate",Now)

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

    Call OutBoxDoc.MakeResponse(MeetingDoc) 'VERY VERY IMPORTANT

    Call OutBoxDoc.ReplaceItemValue("$REFOptions","1") 'VERY VERY IMPORTANT

    Call OutBoxDoc.Send(0)

End Sub

Subject: Some comments

Since you are ‘re-initing’ items in your CreateMeetingDoc routine that you really do not need to, you should have this line:

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

as well. If you decide to pull out the re-initing of items that are not changing (e.g. anything not related to the new start/end times) then you can skip it.

You definitely do not need to do this:

    Call MeetingDoc.Replaceitemvalue("ApptUNID",MeetingDoc.UniversalID) 'THIS ENSURES THAT THE APPUNID HAS NOT CHANGED

since UNIDs never change for a given doc once created. On that topic, your:

    Set MeetingDoc=MailDB.GetDocumentByUNID("STRINGFORMAT OF THE ORIGINAL/FIRST MEETING DOCUMENT UNID")

could simply be clearer by removing references to “original” and “first”. Its really the existing entries UNID so this would be more precise and less confusing:

    Set MeetingDoc=MailDB.GetDocumentByUNID("STRINGFORMAT OF THE MEETING DOCUMENT UNID")

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") 

(if you are still re-initing items) and

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

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

Bruce

IBM