Attach Internal Access Report to Email Item

nschroeder

nschroeder
Local time
Today, 06:02
Joined
Jan 8, 2007
Messages
186
I have a subroutine that works well for sending emails. A need has arisen to, in some cases, send an Access report as a PDF attachment. I know how to do this using the SendObject method, but that won't work in this app. I also don't want to have to first save the report as a pdf file. I think I'm close, but I don't know the syntax for passing the report name as the Source parameter in the Attachments.Add method. Can someone give some direction?

Code:
                    If strEmailAddress = "jsmith" Then
                        .Attachments.Add  source:=MyReportName, type:=acFormatPDF
                    End If
                    On Error GoTo SendErr
                    .Send
                    On Error GoTo 0
 
To use that method, you would first use OutputTo to create the file and then put the path to it in your code.
 
Thanks for your reply. The wording in msdn.microsoft.com for the Attachments.Add Source parameter is:
The source of the attachment. This can be a file (represented by the full file system path with a file name) or an Outlook item that constitutes the attachment.

That gave me the impression that there might be a way to attach internal objects. Apparently that's not the case?
 
Not that I'm aware of, but it wouldn't be the first time I was wrong. An Access report is neither of the items mentioned. I've only used a path, not sure what an Outlook item would be, but it would be something inside Outlook, perhaps an attachment from another email or something.
 
Here's the code I ended up adding, if anyone's interested.
Code:
                    If MsgTo = "jsmith" Then 
                        AttachName = PathName & "TaskList.pdf"
                        DoCmd.OutputTo acOutputReport, "TaskDetailList", acFormatPDF, AttachName
                        .Attachments.Add AttachName, olByValue
                        Kill AttachName
                    End If
 

Users who are viewing this thread

Back
Top Bottom