我试图使用VBA在宏中自动通过电子邮件发送报告。该报告由Outlook2007从Access2007发送。在发送报告时,我从Outlook收到一条安全消息,说“某个程序试图访问您的地址簿或联系人”或“某个程序尝试访问您存储在Outlook中的电子邮件地址...”。此消息对我来说是个问题,因为我想使用Windows任务计划程序自动发送报告而无需任何人为交互。所以我想禁用此安全通知。我在谷歌搜索,这是迄今为止的代码,但给我错误,我不知道我应该做什么。感谢您的帮助提前。我是一名初学者程序员。错误是使用VBA禁用Outlook安全设置
Public Sub Send_Report()
Dim strRecipient As String
Dim strSubject As String
Dim strMessageBody As String
Dim outlookapp As Outlook.Application
Set outlookapp = CreateObject("Outlook.Application")
OlSecurityManager.ConnectTo outlookapp 'error is here says object required
OlSecurityManager.DisableOOMWarnings = True
On Error GoTo Finally
strRecipient = "[email protected]"
strSubject = "Tile of report"
strMessageBody = "Here is the message."
DoCmd.SendObject acSendReport, "Report_Name", acFormatPDF, strRecipient, , , strSubject, strMessageBody, False
Finally:
OlSecurityManager.DisableOOMWarnings = False
End Sub
你是对的,我没有Outlook安全管理插件,我会用你的第二个方法,并更新你我所得到 – guest1
你好。让,我没有看到将您的访问报告附加为PDF格式的观点ond代码。它是否允许发送附件?非常感谢! – guest1
感谢让您的快速回复!实际上,附件是驻留在Access数据库中的报告。它不从本地驱动器附加文件。为了更清楚地说明,我在Access中有一个数据库,它有一个关于它的报告。我试图直接从Access中自动发送此报告并将其作为附件发送出去。那有意义吗? – guest1