【问题标题】:Access- Email with Attached PDF report访问 - 附有 PDF 报告的电子邮件
【发布时间】:2016-07-19 08:20:13
【问题描述】:

我有一个数据库,该数据库目前向所有有逾期记录的员工发送电子邮件。

我还有一份报告,它每天都会自动保存为 PDF,显示任何过期记录。

我希望正在发送的电子邮件中附上已保存报告文件夹中的最新 PDF 报告。

目前,我的电子邮件附件部分的代码如下,但我不确定如何让它做我想做的事,如上所述:

strAtt = Array("J:\performancereview\coaching\ " & ".pdf")

任何想法将不胜感激?谢谢

【问题讨论】:

    标签: vba email ms-access


    【解决方案1】:

    您是在单个条目的基础上执行此操作,还是在所有员工的循环中执行此操作?

    我们在我们的系统中做类似的事情。我们在查询循环上对其进行操作。

    我们如何做的大致思路是:

    Dim pdfFileName as string
    Dim permail as string
    
    'Open an Rst Record Set
    
    pdfFileName = "Y:\Personnell\" & rst!ID & newfolder & ".pdf" ' Rst!ID is from the query.
    permail = rst![email]
    
    'Save the report from access report using the pdfFileName name construct.
    
                   With oMail
                        .to = permail
                        .htmlBody = "Email Body" ' Enter your email body here
                        .Subject = "Email Subject" ' Enter email subject here
                        .Attachments.Add (pdfFileName)
                        .Send
    
    
                    End With
    rst.MoveNext
    
    Loop
    

    【讨论】:

      【解决方案2】:

      我发现最简单的方法是在文件名中使用日期。 如果您在 pdf 的名称中包含日期,例如。每天逾期01012016.pdf

      stratt = "reportfolderpath\" & "overdue" & replace(date(),"/","") & ".pdf"
      

      【讨论】:

        猜你喜欢
        • 2012-06-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-06-17
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多