How to send a task in VB.Net PDF Print E-mail
Written by J. Bijvoets   
Tuesday, 14 September 2010 08:23

Sending an Outlook task in Visual Basic

The Microsoft Outlook Library 14 offers many powerful tools to use in your Visual Basic code. Here's an example how I send Outlook tasks to colleagues in code:

First, add a reference to the Microsoft Outlook Object Library 14 via Add Reference (COM Objects).

Second, add an import to the top of your file: Imports Outlook = Microsoft.Office.Interop.Outlook

Finally, use the following code:

Dim outlookApp As Outlook.Application = New Outlook.Application()
' Create a new TaskItem.
Dim NewTask As Outlook.TaskItem = CType(outlookApp.CreateItem(Outlook.OlItemType.olTaskItem), Outlook.TaskItem)
' Configure the task at hand and save it.

NewTask.Body = "Programmatically Generated Task:" & vbNewLine & "  Added as demonstration."
NewTask.DueDate = Now.AddMinutes(1.5)
NewTask.Importance = Outlook.OlImportance.olImportanceHigh
NewTask.Subject = "Doe iets op een bepaald moment"
NewTask.ReminderTime = Now.AddMinutes(0.5)
NewTask.ContactNames = " This e-mail address is being protected from spambots. You need JavaScript enabled to view it "
NewTask.Recipients.Add(" This e-mail address is being protected from spambots. You need JavaScript enabled to view it ")

NewTask.Save()
NewTask.Assign() 'Don't forget this line, as I did first &%@%!
NewTask.Send()

If you want to send a normal email, read the page about sending email in code.

Last Updated on Wednesday, 24 November 2010 21:20