Below is a simple function which permits you to use VBA to add a task into Outlook using late binding, so no references are required!
'--------------------------------------------------------------------------------------- ' Procedure : AddOlTask ' Author : CARDA Consultants Inc. ' Website : http://www.cardaconsultants.com ' Purpose : Create a task in Outlook using late binding (no need for references) ' Copyright : The following may be altered and reused as you wish so long as the ' copyright notice is left unchanged (including Author, Website and ' Copyright). It may not be sold/resold or reposted on other sites (links ' back to this site are allowed). ' ' Input Variables: ' ~~~~~~~~~~~~~~~~ ' sSubject : Task subject ' sBody : Task body (the actual content message in the task) ' dtDueDate : Task due date ' dtReminderDate : Task reminder date/time ' ' Usage Example: ' ~~~~~~~~~~~~~~~~ ' ? AddOlTask("Meeting with Daniel","Meeting w/ Daniel to discuss the database.", _ ' #5/31/2010#, #5/29/2010 9:00 AM#) ' ' Revision History: ' Rev Date(yyyy/mm/dd) Description ' ************************************************************************************** ' 1 2010-May-20 Initial Release '--------------------------------------------------------------------------------------- Function AddOlTask(sSubject As String, sBody As String, _ dtDueDate As Date, _ dtReminderDate As Date) On Error GoTo Error_Handler Const olTaskItem = 3 Dim OlApp As Object Dim OlTask As Object Set OlApp = CreateObject("Outlook.Application") Set OlTask = OlApp.CreateItem(olTaskItem) With OlTask .Subject = sSubject .DueDate = dtDueDate .Status = 1 '0=not started, 1=in progress, 2=complete, 3=waiting, '4=deferred .Importance = 1 '0=low, 1=normal, 2=high .ReminderSet = True .ReminderTime = dtReminderDate .Categories = "Business" 'use any of the predefined Categorys or create your own .Body = sBody .Save 'use .Display if you wish the user to see the task form and make 'them perform the save End With Error_Handler_Exit: On Error Resume Next Set OlTask = Nothing Set OlApp = Nothing Exit Function Error_Handler: MsgBox "The following error has occured" & vbCrLf & vbCrLf & "Error Number: " & _ Err.Number & vbCrLf & "Error Source: AddOlkTask" & vbCrLf & "Error Description: " & _ Err.Description, vbCritical, "An Error has Occured!" Resume Error_Handler_Exit End Function


