设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 5897|回复: 3
打印 上一主题 下一主题

[Access本身] 请问用Access实现自动发邮件时,附件可以是报表吗?

[复制链接]
跳转到指定楼层
1#
发表于 2014-9-2 14:02:31 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
下面代码是可以自动发送邮件的功能的,要实现附件是Access报表该怎么改程序?谢谢了
Sub SendMessage(Optional AttachmentPath)
    Dim objOutlook As Outlook.Application
    Dim objOutlookMsg As Outlook.MailItem
    Dim objOutlookRecip As Outlook.Recipient
    Dim objOutlookAttach As Outlook.Attachment
    ' Create the Outlook session.
    Set objOutlook = CreateObject("Outlook.Application")
    ' Create the message.
    Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
    With objOutlookMsg
       ' Add the To recipient(s) to the message.
      Set objOutlookRecip = .Recipients.Add("Nancy Davolio")
       objOutlookRecip.Type = olTo
       ' Add the CC recipient(s) to the message.
       Set objOutlookRecip = .Recipients.Add("Andrew Fuller")
       objOutlookRecip.Type = olCC
       ' Set the Subject, Body, and Importance of the message.
       .Subject = "This is an Automation test with Microsoft Outlook"
       .Body = "Last test - I promise." & vbCrLf & vbCrLf
       .Importance = olImportanceHigh  'High importance
       ' Add attachments to the message.
       If Not IsMissing(AttachmentPath) Then
          Set objOutlookAttach = .Attachments.Add(AttachmentPath)
       End If
       ' Resolve each Recipient's name.
       For Each objOutlookRecip In .Recipients
          objOutlookRecip.Resolve
          If Not objOutlookRecip.Resolve Then
          objOutlookMsg.Display
       End If
       Next
       .Send
    End With
    Set objOutlookMsg = Nothing
    Set objOutlook = Nothing
End Sub
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏1 分享分享 分享淘帖 订阅订阅
2#
 楼主| 发表于 2014-9-2 15:22:21 | 只看该作者
已解决,可用DoCmd.SendObject acReport
3#
 楼主| 发表于 2014-9-2 15:23:14 | 只看该作者
但用上述方法又会出现一个安全提示,怎样屏蔽又是个问题

点击这里给我发消息

4#
发表于 2014-9-18 11:51:06 | 只看该作者
收藏了
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-5-30 18:56 , Processed in 0.101904 second(s), 28 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表