Now here’s a question we see all the time in the various forums.
As usual, there are a number of ways to accomplish this and which one you should use has a lot to do with your needs and abilities.
In this post, I’m going to briefly discuss the 3 most popular approaches:
So let’s dive in!
SendObject Method
The SendObject method is a built-in technique for sending basic e-mails from Access. The basic syntax is
DoCmd.SendObject(ObjectType, ObjectName, OutputFormat, To, Cc, Bcc, Subject, MessageText, EditMessage, TemplateFile)
As you can see, it even enables you to send a database object (table, query, form, report, …) in different formats (HTML, XLS(X), PDF, …).
Pros
- Built-in, so very easy to use
- Can include database objects without extra code
- Sent e-mails are logged in the email client as a sent item
Cons
- Does not support HTML formatted content (no bold, italic, underlines, images, table structures, …)
- Cannot include multiple database objects
- Cannot include external attachments
- Requires an e-mail client be installed
- This method is only available in Access
Outlook Automation
This is pretty much my favorite approach to sending e-mails. Using a function such as the one found at VBA – Send HTML Emails Using Outlook Automation enables, IMHO, the best of both worlds! You can send emails with ease, just use the function (which requires no reference libraries), and it allows for multiple attachments, HTML content, …
Pros
- Supports HTML content
- Supports multiple attachments
- Supports external attachments
- Sent e-mails are logged in Outlook as a sent item
- This form of automation will work in any VBA application (Access, Excel, PowerPoint, Word, …)
Cons
- Requires Outlook be installed on the end-user’s computer
- Slightly more complex coding
- Including database objects requires extra code to first export them to the hard drive before you can include them as an attachment in the email
Thunderbird Automation
As an alternative to using Microsoft Outlook, I have numerous clients using Mozilla Thunderbird as their e-mail client. Similarly to Outlook automation, it is possible to automate Thunderbird using a function such VBA – Send E-mail Using Mozilla Thunderbird and generate HTML e-mails.
Pros
- Supports HTML content
- Supports multiple attachments
- Supports external attachments
- Sent e-mails are logged in Thunderbird as a sent item
- This form of automation will work in any VBA application (Access, Excel, PowerPoint, Word, …)
Cons
- Requires Thunderbird be installed on the end-user’s computer
- Slightly more complex coding
- Including database objects requires extra code to first export them to the hard drive before you can include them as an attachment in the email
- Automating sending the e-mail is more tricky
CDO Mail
In those cases where you need more power than offered by the SendObject method and your end-users don’t necessarily have Outlook as their email client, then this is where CDO Mail comes into the picture.
CDO mail is a technique that interacts directly with the mail server and performs the send directly from there, so no email client is actually required.
Once again, even though the coding can be more complex, the function found at VBA – CDO Mail can greatly help in simplifying its implementation.
Pros
- Supports HTML content
- Supports multiple attachments
- Supports external attachments
- Requires no software to work
- This form of automation will work in any VBA application (Access, Excel, PowerPoint, Word, …)
Cons
- Slightly more complex coding
- Including database objects requires extra code to first export them to the hard drive before you can include them as an attachment in the email
- Requires the developer, or user, knowledge of the server credential to be able to configure the code to function properly
- Sent e-mails are not logged anywhere. This is where including yourself in the To/CC/BCC can become necessary
curl
curl, especially since it is now part of Windows (10 & 11), has become another interesting option for e-mail automation. I should also note that curl does much, much more than just e-mail, it can download files, works as an ftp application, … making it that much more interesting to learn and it cross platform (windows, linux, macOS, …).
An example of its use can be found at VBA – Send Email Using Windows 10 Curl.
Pros
- Supports HTML content
- Supports multiple attachments
- Supports external attachments
- Requires no software to work as it is built-in to Windows 10, 11 (but can also be downloaded and install on systems that don’t have it)
- This form of automation will work in any VBA application (Access, Excel, PowerPoint, Word, …)
- Good documentation and plenty of good reference sites to help with development
Cons
- Slightly more complex coding
- Including database objects requires extra code to first export them to the hard drive before you can include them as an attachment in the email
- Requires the developer, or user, knowledge of the server credential to be able to configure the code to function properly
- Sent e-mails are not logged anywhere. This is where including yourself in the To/CC/BCC can become necessary
Other Techniques
Although the above covers most use cases, there are a number of other techniques that can be employed depending on the situation, and there are even more than the one briefly covered below.
Note that the following are not part of the Demo Database. Refer to the links provided for each for more information, examples, purchase details (if applicable).
BLAT
BLAT is a free command-line utility for sending e-mails. I actually used it as part of one of my very first databases when I was still in the corporate world. It worked beautifully and is very easy to use.
To implement it using VBA, you basically build the necessary command as a string and then use the Shell function to execute it.
vbSendMail
vbSendMail is a free dll based solution for sending e-mail. This is one technique I have not personally used, but several of my fellow MVPs have used it and recommend it.
The major drawback with this approach is that is appears to require installing vbsendmail.dll and the mswinsck.ocx with rgsvr32 and then setting a VBA Reference to SMTP Send Mail for VB6.0.
vbMAPI
vbMAPI is a paid solution created by Wayne Phillips, so you can be sure it is good (all his solutions are top notch)! The advantage over the vbSendMail technique is that there are no external files required (no dlls).
Outlook Redemption
Outlook Redemption is a paid COM library that must be registered on each computer that uses it and can be used in a multitude of programming languages, not just VBA.
FMS Inc’s Total Access Emailer
FMS Inc’s Total Access Emailer is a paid Access Add-In that seamlessly integrates into your Access application.
WinSock API
The built-in WinSock API opens the door to a multitude of possibilities (LAN, FTP, e-mail, and much more). That said, it isn’t for the faint of heart as the coding required is quite extensive and definitely not for the novice programmer. There can be serious security implications, thus requiring a experienced developer to implement this technique properly.
Sample
I’ve put together a sample database that demonstrates all three techniques. Feel free to try it out.
Disclaimer/Notes:
If you do not have Microsoft Access, simply download and install the freely available runtime version (this permits running MS Access databases, but not modifying their design):Microsoft Access 2010 Runtime
Microsoft Access 2013 Runtime
Microsoft Access 2016 Runtime
Microsoft 365 Access Runtime
In no event will Devhut.net or CARDA Consultants Inc. be liable to the client/end-user or any third party for any damages, including any lost profits, lost savings or other incidental, consequential or special damages arising out of the operation of or inability to operate the software which CARDA Consultants Inc. has provided, even if CARDA Consultants Inc. has been advised of the possibility of such damages.
Download a Demo Database
Feel free to download a 100% unlocked demo copy by using the link provided below:
Download “Access – Sending Emails (2007 accdb x32)” Sending-Emails.zip – Downloaded 44772 times – 43.21 KBDownload Version History
| Version | Date | Changes |
|---|---|---|
| V1.000 | 2018-02-18 | Initial Release |
Webpage History
| Date | Summary of Changes |
|---|---|
| 2018-02-16 | Initial Release |
| 2020-05-01 | Added the Other Techniques section |
| 2022-09-29 | Added the Thunderbird Automation section |
| 2024-08-23 | Added the curl section |

Hi I’m about to download and take a look at your code. Definitely will use it if it works for my application. My issue only came up when users migrated to MS Access 2016. Prior to that I had code that beautifully formatted, attached reports and sent mail. Now the code doesn’t even throw back an error.
Can I give you a sample?
I can’t make any promises, but feel free.
That said, the best place to get help is in a community forum. I highly recommend UtterAccess.com!
in your outlook automation example – how would I modify the syntax below to add an attachment
Call SendHTMLEmail(Me.txt_To, Me.txt_Subject, Me.txt_Msg, Me.chk_Edit, Me.txt_BCC)
If you look at the SendHTMLEmail function you’ll see there is a 6th optional input variable for attachments that expects an array. So you can simply do something like
Call SendHTMLEmail(Me.txt_To, Me.txt_Subject, Me.txt_Msg, Me.chk_Edit, Me.txt_BCC, array(“C:\…\file1.ext”, “C:\…\file2.ext”))
As such you can add as many files as you’d like by simply separating them by a comma.
How can I add in “EmailBody” a filed or label from form?
Having a [test] filed, I have tried this but not working:
Call SendHTMLEmail(“RecipientEmail”, “Subject”, “EmailBody” & [test])
If I understand the request properly you would do something along the lines of
Call SendHTMLEmail("RecipientEmail", "Subject", "EmailBody" & Me.test)HI. Its very well tool. Is it possible to give an attachement in CDO Send? tHANKS
Take a look at https://www.devhut.net/2014/11/29/vba-cdo-mail/
Thank you for your article Daniel! I’d be interested in your thoughts of Email Architect’s DLL’s (EAGetMail & EASendMail). I’ve been using them for emailing to/from Access and found them to be very useful. But outside of their own literature, I’ve seen very few people talking about this option. I think it would be great to have someone like you (because of your experience with Web Browser control for HTML email composition) to make a email client in MS Access using the Email Architect libraries. hint, hint! 🙂
Hello Daniel,
Once again I am searching your website for answers.
I oversee sending out our 3-4 times a year newsletters for our small historical society.
My Access form-based procedure in access has worked without fail in the past but now is broken in Windows 11.
It did work in Windows 11 the last time (in August 2023) but now it seems sometimes it works but other times it does not. (The New Outlook was forced on my system somehow and that seems to be the culprit)
In your example Send Email Database none of the Examples work either.
The only one that pops up an error is the CDO example which is
Error Number: -2147220973
Error Source: SendCDOMail
Error Description: The Transport failed to connect to the server.
I received a password code from Google for the google email that I have been using but apparently, I am not applying it correctly somewhere.
I would much prefer to switch my procedure over to CDO example but am stuck.
Any help would be very much appreciated.
You need to enable ‘Allow less secure apps’ in Gmail. Even this will supposedly cease to work in a few month and you will need to shift over to using OAuth 2.0 authentication and API coding.
Hi
I have looked at your SendHTMLEmail for Access.
In the arguments to SendHTMLEmail, there are TO and BCC, but no CC.
Is it possible that you could add the CC to the function?
I have tried to, but cannot see the logic…
Thanks
Take a look at:
VBA – Send HTML Emails Using Outlook Automation
VBA – Send HTML Emails Using Outlook Automation – Improved