How to attach the file?

S

Sri

I have created a report as snp format and I copied that
report in a Excelsheet. That excel sheet resides in my
"c:\windows\desktop\report.xls" Now I need to attach this
file to my mail as attachment when i click the button in
one form . How can I do it ?
I know how to attach report, forms, table by using
docmd.sendobject acsendreport command . But that command
will not work to attach a file which resides out of Access
( it means the file which is not kept in Access Area.)

Thanks
Sri
 
D

Dave Ruhl

I open up Outlook from Access with this command:

DoCmd.SendObject
acReport, "rptMyReport", "Snapshot", , , , "Report Name
Here"

This automatically opens Outlook with this report
attached. I can attach additional files by clicking the
Outlook "Attach" button and browsing anywhere on my
computer (or network).
 
D

Dave Ruhl

I haven't tried this but the online VB Help says that if
you use acSendNoObject (in place of acReport) your mail
application will open with no attachments. Then you can
manually attach any file on your PC or network. There
doesn't seem to be a way to attach a non-database object
to email from Access.

Another solution might be to create a blank report with a
single image Linked (not embedded) to it. In the
report's Open module you can then add code to change the
filepath in the image's Picture property. Thus, a single
report could be used as a way of emailing any image file.
 
D

Dirk Goldgar

Sri said:
I have created a report as snp format and I copied that
report in a Excelsheet. That excel sheet resides in my
"c:\windows\desktop\report.xls" Now I need to attach this
file to my mail as attachment when i click the button in
one form . How can I do it ?
I know how to attach report, forms, table by using
docmd.sendobject acsendreport command . But that command
will not work to attach a file which resides out of Access
( it means the file which is not kept in Access Area.)

Thanks
Sri

It's not clear to me why you're creating your report as a snapshot and
then copying that into an Excel spreadsheet, but that's your lookout.
If you want to automatically attach non-Access objects, such as your
Excel workbook, you can't do it by way of SendObject -- though, as Dave
Ruhl has mentioned, you can use SendObject to create the initial
message, and then manually add the attachment. However, a smoother
solution would be either to automate Outlook or use the Windows
Messaging API to create your message, attach files, and send it. See
Tony Toews' Access Email FAQ at

http://www.granite.ab.ca/access/email.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top