Everybody what everything for nothing.
Depending on your exact needs, it can be done very easily.
If they just want to pull a list of e-mail addresses to populate the To
field and then pop-up open outlook to write their message than yes, it can be
done very quickly.
Build your query (call it for instance qry_email_list)
Then you'd create a button with the following on_click event (or something
similar).
Sub GenEmail()
On Error GoTo Error_Handler
Dim db As Database
Dim rs As Recordset
Dim sTo As String
Set db = CurrentDb()
Set rs = db.OpenRecordset("YourQueryName")
If rs.RecordCount <> 0 Then 'ensure there is at least 1 record to work
with
With rs
.MoveFirst
Do While Not .EOF
sTo = sTo & ![YourQueryEmailAddressFieldName] & ";"
.MoveNext
Loop
End With
DoCmd.SendObject acSendNoObject, , , sTo, , , "YourSubjectTitle", ,
True
Else
MsgBox "There are no e-mail addresses to generate an e-mail with.",
vbInformation + vbOKOnly, "Error"
End If
Error_Handler_Exit:
On Error Resume Next
rs.Close
Set rs = Nothing
Set db = Nothing
Exit Sub
Error_Handler:
If Err.Number <> 2501 Then 'Ignore user cancelled action
MsgBox "MS Access has generated the following error" & vbCrLf &
vbCrLf & "Error Number: " & _
Err.Number & vbCrLf & "Error Source: GenEmail" & vbCrLf & "Error
Description: " & _
Err.Description, vbCritical, "An Error has Occured!"
Resume Error_Handler_Exit
End If
End Sub
--
Hope this helps,
Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples:
http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.