Code to send a PDF email from a Form

sclark

Yamo be there
Local time
Today, 14:37
Joined
Mar 1, 2007
Messages
60
Does anyone know the code to be able to email the pdf version of a form?

I have a form, "MIF2", that I would llike to send via email to "email.address@ somewhere.com" automatically when a command button is clicked in the form. Since this is a form, a macro doesn't seem to work to send object (since it emails the form as a datasheet rather than what should look like the actual form).

I can manually do this via the toolbar: "File", "Send To", "Mail Recipient as Adobe PDF", then fill in the email address on the email. But, thought someone might know the code to do these functions. [The form is always 1 of 1 so I do not have any problem with eamiling all records at once.]
 
Hi,

i am just going through this at the moment so i will share what i have so far.

Firstly you need the addon for the ability to save/send in pdf format. Do a search in the msdn and you will find it. It is free.

Install that.

Next you create your button and you can create either a macro or use vba in your onclick action.

If you use the macro options you can select report operations and then mail report, then select the report you wish to send and finish off the wizard.

If you wish to set further parms you can go an edit the macro and supply the other args.

If on the other hand you wish to do it with VBA checkout the line below.

DoCmd.SendObject acSendReport, "rptJobNameHere", acFormatPDF, , , , "Daily Time Sheets", , True

There are other options like address, cc, bcc etc so have a look at the msdn for the other options.

Hope this helps.

Paul
 
Thanks for sharing

Looks like the downloads are for 2007 only (and I have 2003 at least for now), but thanks anyway.
 
This is working great for me, but if I close the email without sending it I get an error message:

Run-time error '2501' The SendObject action was cancelled.

What can I do to prevent this error from crashing the program?
 

Users who are viewing this thread

Back
Top Bottom