You are currently offline, waiting for your internet to reconnect

How to create an appointment by using Outlook Object Model in Microsoft Visual Basic .NET

This article was previously published under Q313788
This article has been archived. It is offered "as is" and will no longer be updated.
For a Microsoft Visual Basic 6.0 version of this article, see 220595.


This step-by-step article describes how to create an appointment by using Outlook Object Model in Visual Basic .NET.

Create the Sample to Create an Appointment

  1. Start Microsoft Visual Studio .NET.
  2. On the File menu, click New, and then click Project.
  3. Click Visual Basic Projects under Project Types, and then click Console Application under Templates. By default, Module1.vb is created.
  4. Add a reference to the Microsoft Outlook 10.0 Object Library. To do this, follow these steps:
    1. On the Project menu, click Add Reference.
    2. On the COM tab, click Microsoft Outlook 10.0 Object Library, and then click Select.
    3. Click OK in the Add References dialog box to accept your selections. If you are prompted to generate wrappers for the library that you selected, click Yes.
  5. In the Code window, replace all of the code with the following:
    Imports System.ReflectionModule Module1    Sub Main()        ' 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("YourValidProfile", Missing.Value, False, True) ' TODO:        ' Create a new AppointmentItem.        Dim oAppt As Outlook.AppointmentItem = oApp.CreateItem(Outlook.OlItemType.olAppointmentItem)        'oAppt.Display(true)  'Modal	        ' Set some common properties.        oAppt.Subject = "Created using OOM in C#"        oAppt.Body = "Hello World"        oAppt.Location = "Samm E"        oAppt.Start = Convert.ToDateTime("11/30/2001 9:00:00 AM")        oAppt.End = Convert.ToDateTime("11/30/2001 1:00:00 PM")        oAppt.ReminderSet = True        oAppt.ReminderMinutesBeforeStart = 5        oAppt.BusyStatus = Outlook.OlBusyStatus.olBusy  '  olBusy        oAppt.IsOnlineMeeting = False        ' Save to Calendar.        oAppt.Save()        ' Display.        'oAppt.Display(true)        ' Logoff.        oNS.Logoff()        ' Clean up.        oApp = Nothing        oNS = Nothing        oAppt = Nothing    End SubEnd Module					

  6. Modify the code where you see the TODO comments.
  7. Press F5 to build and run the program.
  8. Verify that the appointment is created.
Back to the top

Article ID: 313788 - Last Review: 12/07/2015 08:15:55 - Revision: 4.3

Microsoft Office Outlook 2003, Microsoft Outlook 2002 Standard Edition, Microsoft Visual Basic .NET 2003 Standard Edition, Microsoft Visual Basic .NET 2002 Standard Edition

  • kbnosurvey kbarchive kbhowtomaster KB313788