How to create a meeting request by using the Outlook Object Model in Visual Basic .NET (313789)
The information in this article applies to:
- Microsoft Outlook 2002
- Microsoft Visual Basic .NET (2003)
- Microsoft Visual Basic .NET (2002)
This article was previously published under Q313789 SUMMARY This step-by-step article describes how to create a meeting
request by using Outlook Object Model in Visual Basic .NET. Create the Sample to Create a Meeting Request- Start Microsoft Visual Studio .NET.
- On the File menu, click New, and then click Project.
- Click Visual Basic Projects under Project Types, and then click Console Application under Templates. By default, Module1.vb is created.
- Add a reference to the Microsoft Outlook 10.0 Object
Library. To do this, follow these steps:
- On the Project menu, click Add Reference.
- On the COM tab, click Microsoft Outlook 10.0 Object
Library, and then click Select.
- In the Add References dialog box, click OK to accept your selections. If you are prompted to generate
wrappers for the libraries that you selected, click Yes.
- In the Code window, replace all of the code with the
following:
Imports System.Reflection
Module Module1
Sub Main()
' Create an Outlook application.
Dim oApp As Outlook.Application = New Outlook.Application()
' Get Mapi NameSpace and Logon.
Dim oNS As Outlook.NameSpace = oApp.GetNamespace("mapi")
oNS.Logon("YourValidProfile", Missing.Value, False, True) ' TODO:
' Create an AppointmentItem.
Dim oAppt As Outlook._AppointmentItem = oApp.CreateItem(Outlook.OlItemType.olAppointmentItem)
'oAppt.Display(true) 'Modal
' Change AppointmentItem to a Meeting.
oAppt.MeetingStatus = Outlook.OlMeetingStatus.olMeeting
' Set some common properties.
oAppt.Subject = "Created using OOM in VB.NET"
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
oAppt.AllDayEvent = False
' Add attendees.
Dim oRecipts As Outlook.Recipients = oAppt.Recipients
' Add required attendee.
Dim oRecipt As Outlook.Recipient
oRecipt = oRecipts.Add("UserTest1") ' TODO:
oRecipt.Type = Outlook.OlMeetingRecipientType.olRequired
' Add optional attendee.
oRecipt = oRecipts.Add("UserTest2") ' TODO:
oRecipt.Type = Outlook.OlMeetingRecipientType.olOptional
oRecipts.ResolveAll()
'oAppt.Display(true)
' Send out request.
oAppt.Send()
' Logoff.
oNS.Logoff()
' Clean up.
oApp = Nothing
oNS = Nothing
oAppt = Nothing
oRecipts = Nothing
oRecipt = Nothing
End Sub
End Module
- Modify the code where you see the TODO comments.
- Press F5 to build and run the program.
- Verify that the meeting is created.
Back to the top
REFERENCES For more information, visit the following Microsoft Web
site:
Back to the top
Modification Type: | Major | Last Reviewed: | 1/19/2006 |
---|
Keywords: | kbHOWTOmaster KB313789 kbAudDeveloper |
---|
|