Peter's Software
Helping you create better Microsoft Access applications


Home

General info

Where to buy

Mailing List

Contact


Links


 

Send an E-Mail Message from MS Access

It's easy! You need an e-mail program that uses MAPI, like Outlook Express. Put this code in a command button OnClick event procedure:

DoCmd.SendObject _
    , _
    , _
    , _
    "ToJohn@doe.com", _
    , _
    , _
    "Subject", _
    "Message", _
    False

The above example will put an e-mail message to "ToJohn@doe.com" into your Outbox. To have the e-mail send window pop up, change the last parameter to "True". To send to more addresses, separate the addresses with a semicolon.

Here's another example that shows where to put CC and Bcc addresses:

DoCmd.SendObject _
    , _
    , _
    , _
    "ToJohn@doe.com;ToBill@doe.com", _
    "CcMary@doe.com", _
    "BccSue@doe.com", _
    "Subject", _
    "Message", _
    False

E-MAIL THE OUTPUT OF A REPORT FROM ACCESS

Here's an example of how to send the output of a report named "Sales By Order" via e-mail. If your report prompts you for parameters, you will be prompted for them when you run this command:

DoCmd.SendObject _
    acSendReport, _
    "Sales By Order", _
    acFormatRTF, _
    "ToJohn@doe.com", _
    , _
    , _
    "Subject", _
    "Message", _
    False

The "acFormatRTF" parameter will send the report output in a format that can be read by MS Word. You can also use:

"acFormatHTML" - Your sent report output will be opened with a web browser.
"acFormatTXT" - Your sent report output will be opened with notepad, or wordpad.

E-MAIL AN ATTACHMENT

To include an attachment with your e-mail, you need to use automation and MS Outlook or some other third-party e-mail software because the SendObject method doesn't have the ability to include an attached file.

A subroutine you can use to send an e-mail message with an attachment through MS Outlook is here. Please note that a reference to Outlook is required.

MORE INFORMATION

More information about sending e-mail from MS Access can be found here: Microsoft Access Email FAQ.

 

More...

You can use our ShrinkerStretcher add-on to scale your forms to fit any end user screen resolution.

You can copy protect your distributed application with KeyedAccess.

You can easily manage table connections to back-end database(s) with our TableLinker utility.