首页 > 解决方案 > 在 Windows 10 上使用 VB6 错误通过 Outlook 发送电子邮件:运行时 287 - 应用程序定义或对象定义错误

问题描述

我们在 Windows 7 和 Windows 10 上运行旧的 Visual Basic 6 应用程序。

其中一项功能是通过 Outlook 桌面客户端发送外发电子邮件。

适用于 Windows 7 机器的相同应用程序不适用于 Windows 10 PC。在 Windows 10 PC 上不发送电子邮件。

Public Sub SendOlMail(Subject As String, attachment As String, Recipient As String, bodytext As String)

Const olMailItem = 0

Dim objOutl As Object
Dim objMailItem As Object

Set objOutl = CreateObject("Outlook.Application")
Set objMailItem = objOutl.CreateItem(olMailItem)

objMailItem.Recipients.Add Recipient
objMailItem.Subject = Subject
objMailItem.Body = bodytext
objMailItem.Attachments.Add attachment
objMailItem.Send

Set objMailItem = Nothing
Set objOutl = Nothing

End Sub

删除后On Error Resume Next,我在 Windows 10 PC 上收到错误消息。

运行时 287 - 应用程序定义或对象定义的错误

我发现错误在线objMailItem.Recipients.Add Recipient,并且看起来像是在 Windows 10 PC 中遗漏了一些东西。

尝试以管理员身份运行该应用程序,但仍然无法正常工作。

标签: outlookvb6

解决方案


推荐阅读