Simple Email Code: Send an email while looking at a Form

travismp

Registered User.
Local time
Today, 18:33
Joined
Oct 15, 2001
Messages
386
I searched a lot of forums, but all the answers are really advanced. I want a very simple (one line) code.

Form: "frm_ORDERS"
Field: "OrderNumber"

I want someone to click a button while on the form "frm_ORDERS" to have an email sent to "xxx@xxx.com" (Email address will always be the same.)

I want the email to be very basic. And only list the "OrderNumber" and maybe some extra text like:

"The Order# XXX has just been placed. Please review and fill."

Is there a quick and easy script for something like this?

Thank you all.
 
This is not my preferred way to handle e-mail, but if you are looking for one line of code....

Code:
docmd.SendObject ,,,"xxx@xxx.com",,,"Subject","The Order# " & Me!OrderNumber & " has just been placed. Please review and fill."
 
Last edited:
Thank you... if there is a better way I am all ears. I would love any tips that would make it a better database overall.

T
 
The better solution is probably the answers that you were getting previously. I know there are many of them floating around this forum. It is a bit more involved, but it is best because you have greater control over the e-mail itself.

http://www.access-programmers.co.uk/forums/showthread.php?t=83814&highlight=send+email is a good example.

It allows you to add multiple attachments, though you do not have to use the functionality. All that is really required to add this into your database is copying and pasting the code into a new module. You can then call it from your button using as much or as little of the functionality you desire. If you do not anticipate other situations arising where you will need to send e-mails, then you probably do not need to implement this type of code.

I am not aware of any perfomrance issues with using docmd.sendobject, even though it was designed for sending objects from the database itself (I just had you leave those variables out). I just like having something more robust, especially for attachments.

You do probably at least want to add an error handler, because if the user elects not to send the e-mail, they will get a runtime error. You can make it so they don't have a choice, but I know that at least my version of outlook doesn't really like that (It prompts the user that it is taking place and gives them a chance to cancel. If they let it send, it shows up red in the inbox).
 

Users who are viewing this thread

Back
Top Bottom