Intellisense says that
Interface "outlook.item" cannot be indexed because it has not default property.
I believe it said "outlook.items". Yes, you have to use Item property of Outlook.Items collection.
I partly rewrote the OP's code. Simply commented out some lines, added few properties for the appointment and fixed the error mentioned above
Dim objOutlook As Outlook.Application
objOutlook = New Outlook.Application()
Dim objNS As Outlook.NameSpace = objOutlook.Session
'---------Write to Shared calendar-----------------
'Dim objFolder As Outlook.MAPIFolder = objNS.Folders.Item("Public Folders")
Dim objFolder As Outlook.MAPIFolder = objNS.Folders.Item("Personal Folders")
'objFolder = objFolder.Folders.Item("All Public Folders")
'objFolder = objFolder.Folders.Item("Boss Calendar")
objFolder = objFolder.Folders.Item("Calendar")
'=========Add appointment to calendar=================
Dim objApp As Outlook.AppointmentItem
objApp = CType(objFolder.Items.Item(Outlook.OlItemType.olAppointmentItem), Outlook.AppointmentItem)
With objApp
.Subject = (" Test appointment")
.Location = "Main Office"
.Body = ("test appointment")
.Start = CDate("19.5.2009 10:00") ' NOTICE: This is my locale date format
' Added a reminder
.ReminderMinutesBeforeStart = 60
.ReminderSet = True
' Added duration
.Duration = 120
' Add logged in Windows user
.RequiredAttendees = Environment.UserName
' Save first
.Save()
' Send to logged in Windows user
.Send() ' NOTICE: Outlook security settings may prevent this
End With
'\\\\\\\\\
If you don't need to invite anyone i.e. just add an appointment in your own calendar, remove lines .RequiredAttendees = Environment.UserName and .Send() . I wasn't able to fully test appointment sending but I think it's very close to what it should be.
Teme64
Veteran Poster
1,031 posts since Aug 2008
Reputation Points: 218
Solved Threads: 203
I'm glad you got it helpful. If you want to ask question, start your own thread.
Thread Closed.
__avd
Posting Genius (adatapost)
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241