wondering if it can be done (1 Viewer)

jamesmor

Registered User.
Local time
Today, 16:54
Joined
Sep 8, 2004
Messages
126
I have a database that automatically emails people based on different events etc. currently I have the email addresses hard coded, and have the following question.

Is there a way that I can put a flag in a table to specify wether or not someone gets an email for a specific category?

for example. If someone does something outside the bounds of what they are supposed to, or if the database throws an error myself and 1 other person get an email sent to them from the client's computer.

Does access have a way for the database to check a table, find out who is supposed to get the email, then send one email to all people who are supposed to recieve it?

I know I could do this with a recordset sending out one email per person that is supposed to recieve it, but in this case I just want to send 1 email and have everyone on it.

Any help is greatly appreciated.
 

bonekrusher

Registered User.
Local time
Today, 14:54
Joined
Nov 19, 2005
Messages
266
yes. Use a Query
You can search a table based on criteria. Use a check box. If the value of the check box =-1 then they get an Email, if its 0, they dont
 

jamesmor

Registered User.
Local time
Today, 16:54
Joined
Sep 8, 2004
Messages
126
bonekrusher said:
yes. Use a Query
You can search a table based on criteria. Use a check box. If the value of the check box =-1 then they get an Email, if its 0, they dont

My next question would be, if I did it this way, wouldn't I be sending an email per person, so if I had 30 people that got the email I'd send 30 emails?

What I'm wanting to do (I didn't explain very well now that I look at it) is:

If there is 1 person send 1 email, if there are 30 people send 1 email.
 

bonekrusher

Registered User.
Local time
Today, 14:54
Joined
Nov 19, 2005
Messages
266
You can put all the email addresses in a String. This is based on a table called "names", if the field admin is -1 then they get compiled in a string and emailed.

Code:
Dim EmailItem As Object
Dim fullname As String
Dim EMailComment
Dim rst As DAO.Recordset
Dim rrst As DAO.Recordset
Dim strEmailAddress As String
Set OL = CreateObject("Outlook.Application")
Set EmailItem = OL.CreateItem(olMailItem)
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("names")

While Not rst.EOF
   If rst![admin] = -1 Then strEmailAddress = strEmailAddress & "; " & rst![EMAIL]
   rst.MoveNext
Wend
strEmailAddress = Left(strEmailAddress, Len(strEmailAddress))

With EmailItem
        With EmailItem
            .Subject = "QA Audit Schedule for " & Date
            .Body = EMailComment
            .To = strEmailAddress
            .Importance = olImportanceHigh
            .Send
        End With
                        
End With
 
Last edited:

jamesmor

Registered User.
Local time
Today, 16:54
Joined
Sep 8, 2004
Messages
126
that's exactly what I was looking for! Thank you so much!
 

Users who are viewing this thread

Top Bottom