Create meetings with LotusScript

From a custom database, I am sending meetings out to people’s mail files. I have this working generally OK - I send an Appointment to the chair, and a Notice to each invitee, and I make sure ApptUNID matches and everything seems to work mostly fine. I have come up with an issue though:

The chair reschedules the meeting. An invitee who hasn’t accepted the original invite, then tries to accept the original invite after the meeting has been rescheduled. This invitee gets this message:

“The entry that has been rescheduled is no longer in your calendar. Should Notes recreate the entry so that it can be rescheduled? (Note that recreating the entry may take some time)”

When I try to recreate this scenario with a manually created meeting, the message I get is something like:

“You have not accepted the meeting invitaion but there is a reshcedule. Would you llike to open the reschedule now?”

Does anyone have any idea what I might be missing with the meetings that I create with LotusScript?

Any help greatly appreciated.

I have seen these documents and tried everything I can think of based on then:

http://www-1.ibm.com/support/docview.wss?rs=463&context=SSKTMJ&dc=DB520&uid=swg21229486&loc=en_US&cs=UTF-8&lang=en&rss=ct463lotus

http://www-12.lotus.com/ldd/doc/uafiles.nsf/docs/WPNotesCSSchema/$File/csschema.pdf

It seems that a lot of the extra fields don’t really make any difference - if you skip putting them on yourself, they are added automatically, if you put them in they don’t seem to change any behaviour.

It basically works OK the way it is, nothing is truly broken, it would just be very nice to get these meetings created by LotusScript to behave exactly the same as manually created ones. Thanks again for any help.

Here is the basic idea of the code I have so far:

'create email

Set Letter = db.CreateDocument

Letter.Form = "Appointment"



'set email headers

Letter.Principal = Chair

Letter.ReplyTo = Chair

Letter.SendTo = Chair

Letter.Subject = Subject



'set calendar entry fields

Letter.ApptUNID = ApptUNID

Letter.AppointmentType = "3"

Call Letter.ReplaceItemValue( "_ViewIcon", 158 )

Letter.Topic = Subject

Letter.Chair = Chair

Letter.RequiredAttendees = Invitees



Letter.StartDateTime = StartDate

Letter.StartTimeZone = TimeZone

Letter.EndDateTime = StartDate

Letter.EndTimeZone = TimeZone

Letter.CalendarDateTime = StartDate



'set body

'blah blah blah



Call Letter.Send( False )

That sends the meeting to the chair.

Here are the only differences for what gets sent to each invitee:

Letter.Form = "Notice"



Letter.SendTo = Invitee

Letter.Subject = "Invitation: " & Subject & " (" & Format( StartDate, "mmm d hh:mm AM/PM" ) & ")"


Letter.NoticeType = "I"

Call Letter.ReplaceItemValue( "_ViewIcon", 133 )

Any ideas?

Subject: create meetings with LotusScript

I’ve been watching your post and now it’s a week later and no one has responded. I don’t have a solution however I might have an idea. I’m posting, below, a bunch of lotusscript. Paste the whole thing into a new action (paste into Declarations) in your inbox folder Action Button. Ask someone to send you a meeting invitation and before you open it… while you have it selected… press this action button. You will then see notepad popup the meeting invite with all the fields and their values. You could select and paste into excel (fields are in 1st column) or print it out and compare what fields are used when notes does this to compare with the fields you’re using in your code. - Maybe this can help… I hope.

’ paste entire code into Declarations

Dim SortedArray As Variant

Const OutputFile = “C:\NotesDocItems.txt” ’ < ----------- FILENAME

Sub DoQS( sA() As String, bottom As Long, top As Long )

Dim length As Long

Dim i As Long

Dim j As Long

Dim Pivot As Long

Dim PivotValue As String

Dim t As String

Dim LastSmall As Long

length = top - bottom + 1

’ Only do the QuickSort if the sublist is at least 10 items long

If length > 10 Then

’ Pivot is chosen approx. halfway through sublist.

’ This gives us best speed if list is almost sorted already, and is no worse than any

’ other choice if the list is in random order.

Pivot = bottom + (length \ 2)

’ Move PivotValue out of the way

PivotValue = sA( Pivot )

sA ( Pivot ) = sA ( bottom )

sA ( bottom ) = PivotValue

’ LastSmall is the location of the last value smaller than PivotValue

LastSmall = bottom

For i = bottom + 1 To top

If sA ( i ) < PivotValue Then

LastSmall = LastSmall + 1

t = sA ( i )

sA ( i ) = sA ( LastSmall )

sA ( LastSmall ) = t

End If

Next

’ Move the PivotValue back

t = sA ( LastSmall )

sA ( LastSmall ) = sA ( bottom )

sA ( bottom ) = t

Pivot = LastSmall

’ Now sort each side

Call DoQS ( sA, bottom, Pivot - 1 )

Call DoQS ( sA, Pivot + 1, top )

End If

End Sub

Sub DoInsertSort ( sA() As String, Byval bottom As Long, Byval top As Long )

Dim i As Long

Dim x As Long

Dim v As String

Dim Found As Integer

For i = bottom+1 To top

x = i

v = sA (i )

Do While (sA(x-1) > v)

sA ( x ) = sA ( x-1 )

x = x - 1

If x=0 Then

Exit Do

End If

Loop

sA (x) = v

Next

End Sub

Function QuickSort(sArray As Variant)

Dim sA() As String

Dim j As Long

Dim bottom As Long

Dim top As Long

bottom = Lbound ( sArray )

top = Ubound ( sArray )

Redim sA( bottom To top ) As String

For j = bottom To top

sA ( j ) = sArray ( j )

Next

’ DoQS does a QuickSort if the Sublist is longer than 10 elements

’ Thus, when DoQS finishes, all elements are within 10 spots of their correct location.

’ For lists that are close to being in order, an Insertion Sort is much faster than a QuickSort,

’ so we run through the whole thing once doing an Insertion Sort to finish tidying up the order.

Call DoQS( sA, bottom, top )

Call DoInsertSort ( sA, bottom, top )

SortedArray = sA

End Function

Sub Click(Source As Button)

Dim S As New NotesSession

Dim W As New NotesUIWorkspace

Dim Db As NotesDatabase

Dim uiDoc As NotesUIDocument

Dim AllDocs As NotesDocumentCollection

Dim Doc As NotesDocument

Dim FieldList()As String

Dim FieldCount As Integer

Dim LastField As String

Dim Unit As Integer

Dim coll As NotesDocumentCollection

Set db = s.CurrentDatabase

Set coll = db.UnprocessedDocuments

Dim i As Integer

Dim f As Integer

i = coll.Count

If i <> 1 Then

Msgbox(“Pick Only 1”)

Goto exitsub

End If

Set doc = coll.GetNthDocument( i )

FieldCount = Ubound(Doc.Items)

Redim FieldList(0 To FieldCount) As String

f = -1

Forall Item In Doc.Items

f = f + 1

FieldList(f) = Item.Name

End Forall

’ Sort the names

On Error Resume Next

Call QuickSort(FieldList)

On Error Goto 0

’ Open the output file.

Unit = Freefile

Open OutputFIle For Output Access Write Lock Write As Unit

’ Loop through the sorted names. Taking one name, loop

’ through the actual items, and for all that match and are

’ saved, write the info to the output file.

LastField = “”

For f = 0 To FieldCount

If SortedArray(f) <> LastField Then

LastField = SortedArray(f)

Forall Item In Doc.Items

If Item.Name = LastField And Item.SaveToDisk Then

Print #Unit, LastField; “:”; Chr$(9); Item.Text

End If

End Forall

End If

Next f

’ Close the output file and we are one.

Close Unit

Msgbox "Document items have been written to " & OutputFile, 0, “Dump Completed”

Dim taskId As Integer

taskId% = Shell("notepad.exe " & OutputFile, 1)

exitsub:

End Sub

Subject: create meetings with LotusScript

I think what you mean is the save and send meeting to invitees doesn’t work, when I tried this it would send me an email showing the meeting and I could accept and it would show in my calendar, but when booking a room it wouldn’t message that room to be reserved…