Creating an email in ACC07

J

Jeffrey Marks

Hi

I'm currently migrating a ACC03 database to an ACC07 database. The
users would like to run a query to generate a list of email addresses,
which would then open an email in Outlook, so they could type in their
message to this list of addresses and then send -- is that possible
and how complicated is it? They're on a tight budget.

Thanks

Jeff
 
D

Daniel Pineault

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.
 

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