通过访问自动通过电子邮件发送报告 [英] Automatically Email Reports From Access

查看:73
本文介绍了通过访问自动通过电子邮件发送报告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在特定时间自动通过Access通过电子邮件发送报告

我真的没有太多在Access中创建宏的经验,但是我尝试创建一个可以在特定时间自动发送电子邮件的宏.到目前为止是这样的:

if [time] = "12:00:00 AM" then
emaildatabaseobject
Object Type Report
Object Name NameofReport
Output Format PDF 
To desiredemail@email.com
CC
BCC
Subject test

解决方案

我个人建议使用MS Access宏单独执行电子邮件操作(可以使用方法. microsoft.com/en-us/office/vba/api/access.docmd"rel =" nofollow noreferrer> DoCmd 对象,或通过在VBA中使用ActiveX自动执行已安装的电子邮件客户端). /p>

然后,您可以使用 Windows Task Scheduler 在给定的时间或给定的时间表上调用MS Access宏.

要创建计划任务以调用MS Access宏,请执行以下步骤:

  • 通过开始"菜单或运行taskschd.msc
  • 在Windows中打开Task Scheduler
  • 从左侧窗格中选择任务计划程序库(或在此下方创建自己的文件夹)
  • 在右侧的操作窗格中,选择创建任务
  • 根据需要填充明显的选项,例如 Name Description 等.
  • 根据您要运行宏的时间/时间表添加触发器.
  • 添加操作,然后选择启动程序
  • 浏览至的位置,然后选择MSACCESS.exe可执行文件.
  • 在"添加参数"编辑框中,指定数据库的文件路径(如果路径包含空格,则用双引号引起来),然后是/x命令行开关和您的宏的名称,例如:

     "C:\Your Folder\Your Database.accdb" /x YourMacro
     

    或者,如果宏中包含SubMacro:

     "C:\Your Folder\Your Database.accdb" /x YourMacro.YourSubMacro
     

    您可以找到有关MS Access可用命令行开关的更多信息

    I would personally suggest using the MS Access Macro to solely perform the emailing operation (either using the EmailDatabaseObject action, SendObject method of the DoCmd object in VBA, or by automating the installed email client using ActiveX in VBA).

    You can then use Windows Task Scheduler to invoke the MS Access Macro at a given time or on a given schedule.

    To create a Scheduled Task to invoke an MS Access Macro, perform the following steps:

    • Open Task Scheduler in Windows either through the Start Menu or by running taskschd.msc
    • Select the Task Scheduler Library from the left-hand pane (or create your own folder beneath this)
    • From the right-hand Actions pane, select Create Task
    • Populate the obvious options such as the Name, Description, etc. as appropriate.
    • Add a Trigger based on the time/schedule on which you wish to run the macro.
    • Add an Action and select Start a Program
    • Browse to the location of and select the MSACCESS.exe executable.
    • In the Add arguments edit box, specify the filepath to your database (enclosed in double quotes if the path contains any spaces), followed by the /x command-line switch and the name of your macro, e.g.:

      "C:\Your Folder\Your Database.accdb" /x YourMacro
      

      Or, if you have a SubMacro within the Macro:

      "C:\Your Folder\Your Database.accdb" /x YourMacro.YourSubMacro
      

      You can find out more about the available command-line switches for MS Access here.

    这篇关于通过访问自动通过电子邮件发送报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆