I have a bit of code that works fine in VBA (e.g., Excel) but fails in VBScript. VBScript does not throw any errors and reports that the code completes with exit code 0, i.e., no problems. If you have Outlook installed then you can probably past the code as is into an Excel VBA and it'll run (although whoever has the someone@gmail.com account will be on your calendar.) What am I missing??
Thanks!
Sub main()
SendCalendarAppt "strSubject", "strBody", "strLocation", "someone@gmail.com", Now()
End Sub
Sub SendCalendarAppt(strSubject, strBody, strLocation, strAttendees, datDateTime)
Dim objOL 'As Outlook.Application
Dim objAppt 'As Outlook.AppointmentItem
Const olAppointmentItem = 1
Const olMeeting = 1
Const olNonMeeting = 0
Set objOL = CreateObject("Outlook.Application")
Set objAppt = objOL.CreateItem(olAppointmentItem)
objAppt.Subject = strSubject
objAppt.Start = datDateTime
objAppt.End = datDateTime + 1
objAppt.Location = strLocation
objAppt.RequiredAttendees = strAttendees
objAppt.MeetingStatus = olMeeting
objAppt.Send
Set objAppt = Nothing
Set objOL = Nothing
End Sub