我有一些代码可以在VBA(例如Excel)中正常工作但在VBScript中失败。 VBScript不会抛出任何错误并报告代码以退出代码0完成,即没有问题。如果您安装了Outlook,那么您可以将代码原样运行到Excel VBA中并运行(尽管拥有someone@gmail.com帐户的任何人都将在您的日历上。)我错过了什么?< / p>
谢谢!
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