Reputation: 461
I wrote a script that should open a calender (Wartung
) in outlook and add the meeting. But i get an "object not found error" in my script.
I also tried Set outtest = outApp.CreateItem(olAppointmentItem)
, that works but only for my personal calender. "Wartung
" is a shared calender.
Dim OutApp As Outlook.Application
Dim outtest As Object
Dim ZeitEnd As Date
Set OutApp = GetOutlook
Set outtest = OutApp.GetNamespace("MAPI").Folders("Meine Kalender").Items("Wartung").CreateItem(olAppointmentItem)
ZeitEnd = DateAdd("h", 4, lstZeit)
With outtest
.Subject = "SAP Patche: " & lstSID
.Start = lstDat + lstZeit
.End = lstDat + ZeitEnd
.Body = "TEST"
'Params not in use
'.AllDayEvent = True
'.MeetingStatus = olMeeting
.Display
End With
Set OutApp = Nothing
Set outtest = Nothing
For a better view:
Upvotes: 0
Views: 58
Reputation: 9199
If you had broken up
Set outtest = OutApp.GetNamespace("MAPI").Folders("Meine Kalender").Items("Wartung").CreateItem(olAppointmentItem)
the highlight indicating the line with the error would be more focused.
Wartung is a folder.
You can Add items to non default folders.
The code could look something like this.
Dim OutApp As Outlook.Application
Dim OutNs As Outlook.Namespace
Dim outCal as Folder
Dim outCalitems as items
Dim outtest as Object
Set OutApp = GetOutlook
Set OutNs = OutApp.GetNamespace("MAPI")
Set outCal = OutNs.Folders("Meine Kalender")
Set outCal = outCal.Folders("Wartung")
Set outCalitems = outCal.Items
Set outtest = outCalitems.Add(olAppointmentItem)
Upvotes: 1