VS 2005: How to run Sample "How to: Create Appointments "
-
Wednesday, November 23, 2005 10:54 AMI did a ful install of VS 2005 Pro, created a new project (VB, Windows App), pasted the code from "How to: Create Appointments ", added Reference to Outlook 11.0 Object Library but still get errors:
Outlook is not declared, Outlook.Recipient is not defined
What do I miss?Private Sub AddAppointment()
Dim newAppointment As Outlook.AppointmentItem = Me.CreateItem (Outlook.OlItemType.olAppointmentItem)
Try
With newAppointment
.Start = Date
.Now.AddHours(2)
.End = Date.Now.AddHours(3)
.Location = "ConferenceRoom #2345"
.Body = _ "We will discuss progress on the group project."
.Subject = "Group Project"
.AllDayEvent = False
.Recipients.Add("Roger Harui")
Dim sentTo As Outlook.Recipients = .Recipients
Dim sentInvite As Outlook.Recipient
sentInvite = sentTo.Add("Holly Holt")
sentInvite.Type = Outlook.OlMeetingRecipientType.olRequired
sentInvite = sentTo.Add("David Junca")
sentInvite.Type = Outlook.OlMeetingRecipientType.olOptional
sentTo.ResolveAll()
.Save()
.Display(True)
End With
Catch ex As Exception
MessageBox.Show("The following error occurred: " & ex.Message)
End Try
End Sub
All Replies
-
Wednesday, November 23, 2005 3:22 PM
Hi,
Im not sure but I think you have to instantiate if thats the right term outlook itself. Try:
Private Sub AddAppointment()
Dim outObj As Outloook.Application 'References app...
Dim newAppointment As Outlook.AppointmentItem = Me.CreateItem (Outlook.OlItemType.olAppointmentItem)
Try
With newAppointment
.Start = Date
.Now.AddHours(2)
.End = Date.Now.AddHours(3)
.Location = "ConferenceRoom #2345"
.Body = _ "We will discuss progress on the group project."
.Subject = "Group Project"
.AllDayEvent = False
.Recipients.Add("Roger Harui")
Dim sentTo As Outlook.Recipients = .Recipients
Dim sentInvite As Outlook.Recipient
sentInvite = sentTo.Add("Holly Holt")
sentInvite.Type = Outlook.OlMeetingRecipientType.olRequired
sentInvite = sentTo.Add("David Junca")
sentInvite.Type = Outlook.OlMeetingRecipientType.olOptional
sentTo.ResolveAll()
.Save()
.Display(True)
End With
Set outObj = Nothing 'tidy
Catch ex As Exception
MessageBox.Show("The following error occurred: " & ex.Message)
End Try
End Sub
-
Thursday, November 24, 2005 12:52 AMModerator
Hi,
Sorry this will not work out for you in VS 2005 pro.
This sample and related Office project support requires that you have Visual Studio Tools for Office. You would need to buy this standalone, or get it as a part of Team System edition. More info about what's included in each product SKU is here:
http://msdn.microsoft.com/vstudio/products/compare/
Best,
Paul Yuknewicz -
Thursday, November 24, 2005 6:26 PMThanks, that is fine.

