NS.GetSharedDefaultFolder 方法的运行时错误
通过 Outlook Interop 库从 MS Access (2007) 运行它。我在一个用户帐户的加星号行中收到错误 -2147221219 (8004011d),但在另一个用户帐户上却没有。错误似乎与权限有关,并且两个帐户都对我尝试打开其日历的帐户具有完全访问权限,并且可以通过 Outlook 打开并创建约会。示例代码
Public Function NewApt(MtgDate As Date, Cat As String)
Dim objOLApp As Outlook.Application
Dim objNS As Outlook.Namespace
Dim objCalendar As Outlook.Folder
Dim NewMtg As Outlook.AppointmentItem
Dim Org As Outlook.Recipient
Set objOLApp = New Outlook.Application
Set objNS = objOLApp.GetNamespace("MAPI")
Set Org = objNS.CreateRecipient("[email protected]")
Org.Resolve
If Org.Resolved Then
** Set objCalendar = objNS.GetSharedDefaultFolder(Org, olFolderCalendar)
Else
MsgBox "Scheduling User failed to resolve, see Crimius."
Exit Function
End If
...
有什么想法吗?
Running it from MS Access (2007) via the Outlook Interop library. I get the error -2147221219 (8004011d) from the starred line on one user account, but not on another. Error appears to be related to permissions, and both accounts have Full Access permissions to the account who's calendar I'm trying to open and can open and create appointments to it via Outlook. Sample code
Public Function NewApt(MtgDate As Date, Cat As String)
Dim objOLApp As Outlook.Application
Dim objNS As Outlook.Namespace
Dim objCalendar As Outlook.Folder
Dim NewMtg As Outlook.AppointmentItem
Dim Org As Outlook.Recipient
Set objOLApp = New Outlook.Application
Set objNS = objOLApp.GetNamespace("MAPI")
Set Org = objNS.CreateRecipient("[email protected]")
Org.Resolve
If Org.Resolved Then
** Set objCalendar = objNS.GetSharedDefaultFolder(Org, olFolderCalendar)
Else
MsgBox "Scheduling User failed to resolve, see Crimius."
Exit Function
End If
...
Any ideas why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我知道可能出现此错误的原因之一。
当您使用
GetSharedDefaultFolder
方法并且参数 1 中的收件人(收件人)在全局地址列表中隐藏时,可能会发生以下错误:I know one reason why this error may appear.
Whe you use the
GetSharedDefaultFolder
method and the recipient in parameter 1 (Recipient) is hidden from the global address list such an error can occur:也许 Outlook 数据文件受密码保护。
切换到 Outlook,输入 Outlook 容器的密码,然后重试。
Maybe, the Outlook-Datafile is protected by password.
Switch to Outlook, enter the Password for the Outlook-Container, and then try again.
我有完全相同的问题。运行多年的 VBA 模块突然拒绝了。经过验证,内部电子邮件地址已更改为之前运行的宏...
更改为电子邮件地址解决了问题。
I had exactly the same issue. A VBA module that ran during years suddenly refused to. After verification it turned out that the internal e-mail addresses changed to previous runs of the macro...
Changing to email addresses solved the problem.