Imports System.Reflection
Module Module1
Sub Main()
Try
' Create an Outlook application.
Dim oApp As Outlook.Application = New Outlook.Application()
' Get NameSpace and Logon.
Dim oNS As Outlook.NameSpace = oApp.GetNamespace("mapi") oNS.Logon("Outlook", Missing.Value, False, True)
' TODO: ' Create a new TaskItem.
Dim OTask As Outlook.TaskItem = App.CreateItem(Outlook.OlItemType.olTaskItem)
' Assign the task
OTask.Assign()
' Add recipients to the task
OTask.Recipients.Add("sridhar@yahoo.com")
' Add the subject to the task
OTask.Subject = "testing for SFA using code"
'Add the body to the task
OTask.Body = "tested by sridhar using code"
' Add the Task duedate
OTask.DueDate = DateTime.Today
' Set the reminder to the task
'oAppt1.ReminderSet = True
' Set the reminder time
OTask.ReminderTime = OTask.DueDate
' If you want to display the task uncomment the next line
'oAppt1.Display(True)
' Save the task to outlook
OTask.Save()
' Send the task
'oAppt1.Send()
Catch ex As Exception
Console.WriteLine(ex.Message)
Finally
' Log off.
oNS.Logoff()
' Clean up.
oApp = Nothing
oNS = Nothing
End Try
End Sub
End Module