标题: 请问用Access实现自动发邮件时,附件可以是报表吗? [打印本页] 作者: XMX64311 时间: 2014-9-2 14:02 标题: 请问用Access实现自动发邮件时,附件可以是报表吗? 下面代码是可以自动发送邮件的功能的,要实现附件是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作者: XMX64311 时间: 2014-9-2 15:22
已解决,可用DoCmd.SendObject acReport作者: XMX64311 时间: 2014-9-2 15:23
但用上述方法又会出现一个安全提示,怎样屏蔽又是个问题作者: 站到终点站 时间: 2014-9-18 11:51
收藏了