I have created this Agent to read an email and create an Appointment from it (it is in a mail-in database set to run when new documents arrive). While this seems to work at this point, it also causes my PC’s system clock to be updated to the same date and time that is in the email’s subject line (where the fields are being read from).
Sub Initialize
Dim Workspace As New NotesUiWorkspace
Dim UiView As NotesUiView
Dim session As NotesSession
Set session = New NotesSession
Dim doc As NotesDocument
Set doc = session.DocumentContext
Dim array As Variant
array = Split(doc.GetFirstItem("Subject").Values(0), "~" )
'PersonToBeInterviewed~DateOfInterview~StartTimeOfInterview~LengthOfTime~NameOfRecruiter~NameOfInterviewer
Set UiView = Workspace.CurrentView
Dim Workspace1 As New NotesUiWorkspace
Call Workspace1.ComposeDocument( "", "", "Appointment" )
Dim Uidoc As NotesUiDocument
Set Uidoc = Workspace1.CurrentDocument
Call UiDoc.FieldSetText("AppointmentType","3")
Call UiDoc.Refresh
Call UiDoc.FieldSetText("Subject","Interview for: " & array(0) )
Call UiDoc.GotoField("StartDate")
Call UiDoc.SelectAll
Call UiDoc.Cut
Call UiDoc.FieldSetText("StartDate",array(1))
Date$ = array(1)
Time$ = array(2)
Dim notesDateTime As New NotesDateTime( Date$ & " " & Time$ )
Call UiDoc.FieldSetText("StartTime", notesDateTime.TimeOnly )
Call notesDateTime.AdjustHour( Val( array( 3 )) )
Call UiDoc.FieldSetText("EndTime", notesDateTime.TimeOnly )
Dim s As Variant
s(1) = Array(5)
Call UiDoc.FieldSetText("RequiredAttendees",s)
Call UiDoc.FieldSetText("Principal",s)
Call UiDoc.FieldSetText("Chair",s)
Call UiDoc.FieldSetText("SendTo",s)
’ Call UiDoc.FieldSetText(“OptionalAttendees”,array(4))
Dim t As Variant
t(1) = "D"
t(2) = "S"
Call UiDoc.FieldSetText("ExcludeFromView", t )
Call UiDoc.Refresh
Call UiDoc.Save
Call UiDoc.Close
Call UiView.Close
End Sub
Does anyone see where this is happening and how I can stop it? Is there an easier way to do what I am trying to do?