sending e-mail from Access

G

Glenn

Here's what I'd like to do in Access, and I'm wondering if someone can tell
me if it is possible, and if so point me to directions on how to accomplish
it.

I have a database that contains a table containing employee information.

Also in the database is a form used to edit the records in the employee
table.

I've set it up so that if certain fields are changed on the form, another
field named "email" is automatically changed to the word "Yes".

What I'd like to do as my next step is have it so that the certain fields of
data from each of the records that has "Yes" in the e-mail are automatically
e-mailed to a specific e-mail address. Then, an update Query is run to
delete the word "Yes" in the e-mail field.

Also, if this is possible, is there a way that it can run automatically at a
certain time each day? I believe I read something about running macros
automatically in another user's post.

Thanks.
 
G

Guest

Hi,
I would suggest you turn your text datatype field which holds the 'yes' into
a boolean datatype which is either true or false based on what you want.
Then create a query or sql statement which filters through the table and
returns all records which have a true (put it in the criteria of the yes/no
field).
Then you have many possible options to loop through your query/sql and email
mails. The simplest email method is the sendobject method, but it is also the
most limited. I will show you a sample code using this method e.g.:

Dim rs As New ADODB.Recordset
Dim strEmail As String

rs.Open "YourQuery", CurrentProject.Connection, adOpenDynamic,
adLockOptimistic

strEmail = ""
Do While Not rs.EOF
strEmail = rs!emails
DoCmd.SendObject , , , strEmail, , , "test", "Test", True
rs.MoveNext
Loop

rs.Close
Set rs = Nothing

After that code run an update sql statement or execute a saved update query
to set the boolean field back to False.
If you want to execute this at certain times you can use a macro which calls
this routine. You can then use the windows scheduler to call this
macro...make sure the last action is to shut down the db.
You can read more about this here:
http://support.microsoft.com/?kbid=230575
HTH
Good luck
 
G

Guest

Yes you can do "most" of what you want.
1st search the help (F1) for "Macros" SendObject" and this will explain the
basic methods of sending mailing on responce to an action (which could be the
"Yes" text in a field, or a button, or anything else)
Next note that Outlook will stop you sending the e mail without some input -
you normally have to press a button in the Outlook popup (It will say
something like " a programme is trying to send an e mail - Allow Yes/No)
The word yes can be deleted from the same macro that sends the email (use
the setvalue macro for the text box with "yes" in it)

Hope this helps
 

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