【发布时间】:2021-02-26 01:22:07
【问题描述】:
我们的电子邮件系统正在更新为 Exchange 365。我有一个数据库正在将日历事件(员工休假)添加到公用文件夹。
嗯,更新后的 Exchange 不使用公用文件夹。因此,我们创建了一个用户并共享了日历,现在我正在尝试找出通过 Access 2016(希望是 2012 年)在另一个用户的日历中添加/更改/删除事件的代码。
下面的代码是我只是想弄清楚如何添加所以没有错误检查。事实上,我就是为此创建了一个数据库。
我确实想出了如何将它添加到我自己的日历中,但是将它添加到新的 Exchange 365 用户日历中不起作用。这是我的代码:
Private Sub Command15_Click()
Dim outMail As Outlook.AppointmentItem
Dim objNS As Outlook.NameSpace
Dim objFolder As Outlook.MAPIFolder 'get name of other persons folder
Dim objRecip As Outlook.Recipient 'other persons name
Dim strName As String 'the name or email of the persons folder
Dim objAppt As Outlook.AppointmentItem
Dim objApp As Outlook.Application
On Error Resume Next
' name of person whose Calendar you want to use - right
strName = "janet 2"
Set objNS = objApp.GetNamespace("MAPI")
Set objRecip = objNS.CreateRecipient(strName)
Set objFolder = objNS.GetSharedDefaultFolder(objRecip, olFolderCalendar)
'Set outMail = Outlook.CreateItem(olAppointmentItem)
Set outMail = objFolder.Items.Add
outMail.Subject = "test"
outMail.Location = ""
outMail.MeetingStatus = olMeeting
outMail.Start = Me.BegDate
outMail.End = Me.BegTime
outMail.RequiredAttendees = strName
outMail.Body = "test message"
outMail.Save
'Set outMail = Nothing
End Sub
【问题讨论】:
-
On Error Resume Next隐藏错误。使调试变得不可能。导致一个糟糕的问题,因为没有关于结果的信息。 -
那么当您单步执行代码时会发生什么?