VBA 无法发送日历约会
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7604670/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
VBA can't send calendar appointment
提问by FizzBuzz
When I manually make a calendar reminder/appointment, I can then click "Invite Attendees" and chose the people to invite and then click "Send" and everyone will receive that calendar reminder/appointment.
当我手动进行日历提醒/约会时,我可以单击“邀请参加者”并选择要邀请的人,然后单击“发送”,每个人都会收到该日历提醒/约会。
I have the following code to make a reminder programmatically, but it won't send to the intended recipients. If I open the reminder after the script has run and click on "Invite Attendees" I can see the list is filled with the people I want to send the reminder to, so I'm not really sure why it's not actually sending the reminder to them.
我有以下代码以编程方式进行提醒,但它不会发送给预期的收件人。如果我在脚本运行后打开提醒并单击“邀请参加者”,我可以看到列表中填满了我想要向其发送提醒的人,所以我不确定为什么它实际上没有将提醒发送给他们。
Can anyone shed some light on this for me?
任何人都可以为我解释一下吗?
Private Function CreateAppointment(SubjectStr As String, BodyStr As String, StartTime As Date, EndTime As Date, AllDay As Boolean)
Dim olApp As Outlook.Application
Dim Appt As Outlook.AppointmentItem
' Only create the reminder if there's no duplicate
If (CheckForDuplicates(SubjectStr) = False) Then
Set olApp = CreateObject("Outlook.Application")
Set Appt = olApp.CreateItem(olAppointmentItem)
Appt.Recipients.Add ("John Doe")
Appt.Recipients.ResolveAll
Appt.Subject = SubjectStr
Appt.Start = StartTime
Appt.End = EndTime
Appt.AllDayEvent = AllDay
Appt.Body = BodyStr
Appt.ReminderSet = True
Appt.Save
Appt.Send
End If
Set Appt = Nothing
Set olApp = Nothing
End Function
采纳答案by JimmyPena
A meeting is a specific type of appointment -- an appointment that other people are invited to.
会议是一种特定类型的约会——邀请其他人参加的约会。
In order to make an appointment a meeting, you need to do more than just invite attendees. You need to set the status to 'Meeting'. Add this to your code:
为了预约会议,您需要做的不仅仅是邀请与会者。您需要将状态设置为“会议”。将此添加到您的代码中:
Appt.MeetingStatus = olMeeting
Also note that you set a reminder, but didn't set a reminder time. For example,
还要注意你设置了提醒,但没有设置提醒时间。例如,
Appt.ReminderMinutesBeforeStart = 30
Finally, if this is Outlook VBA, why are you using CreateObject? You should be using the native Application Object to derive all your objects.
最后,如果这是 Outlook VBA,为什么要使用 CreateObject?您应该使用本机应用程序对象来派生所有对象。
i.e. instead of
即代替
Set olApp = CreateObject("Outlook.Application")
you would use
你会用
Set olApp = Outlook.Application
HTH
HTH
回答by Chris
I had the same issue, didn't get it to work until I replaced
我有同样的问题,直到我更换它才开始工作
Appt.Recipients.Add ("John Doe")
Appt.Recipients.ResolveAll
With
和
Appt.RequiredAttendees = "[email protected]"
Regards
问候
Chris
克里斯