Function CreateTask(assignedTo As String, subject As String, startDate As String
, dueDate As String, body As String, import As Variant, linkto As notesdocument,
categoryText As String) As Integer
%REM
'This function creates a Notes TASK (ToDo) in the mail database
Parameters:
1. assignedTo - Type String. A person name.
2. subject - Type String. The task subject.
3. startDate - Type Variant. The starting date of the task.
4. dueDate - Type Variant. The completion date of the task.
5. body - Type String. The contents of the task body.
6. import - Type Variant. The importance of the task. 1=High, 2=Medium, 3=Low
7. linkto - Type NotesDocument. Used to create a doclink.
8. categoryText - Type String. The task category.
Example of Usage:
subject = "Custom Subject"
completion by " & [Link](0)
startdate = Today
duedate = Cdat([Link](0))
assignedTo = [Link](0)
body = "Custom Body" & Chr(10)
cat = "SIU"
-->> Call SendTask(assignedTo, subject, startdate, duedate, body, "1", doc,
cat)
%END REM
Dim ws As New NotesUIWorkspace
Dim rtitem As NotesRichTextItem
Dim todoDoc As NotesDocument
Dim maildb As New NotesDatabase( "", "" )
Call [Link]
Set todoDoc = New NotesDocument(maildb)
'Setup error handling
On Error Goto ErrorHandler
'Populate task fields
With todoDoc
.Form = "Task"
.Subject = subject
.StartDate = Cdat(startdate & " [Link] PM")
.DueDate = Cdat(duedate & " [Link] PM")
.DueDateTime = Cdat(duedate & " [Link] PM")
.CalendarDateTime = Cdat(startdate & " [Link] PM")
.Importance = import
.AssignedTo = assignedto
.Chair = assignedTo
.CopyTo = copyto
.Categories = categoryText
.TaskType = "1"
.tmpOwnerHW = "1"
.tmpNoActionBar = "1"
.NoticeType = ""
.~_ViewIcon = 8
End With
'Handle the rich text Body field and doclink
Set rtItem = [Link]("Body")
Call [Link](2)
Call [Link](body)
If Not( linkto Is Nothing) Then
Call [Link](2)
Call [Link]("Click link to open document -->")
Call [Link](linkto, "Click link to open document")
End If
'Save the Task (ToDo) document
Call [Link](False, False)
Call [Link](True, False)
If (Msgbox("A new task was created and saved." & Chr(10) & "Would you li
ke to edit this task now?", 36, GetTitle())) = 6 Then
'Display the newly created task in edit mode
Call [Link](True, todoDoc)
End If
'Return a success
SendTask=True
Exit Function
ErrorHandler:
Print ( "Error " & Str$(Err) & ": " & Error$ )
Resume TheEnd
TheEnd:
'Return a failure
SendTask = False
End Function