Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

email address list

Status
Not open for further replies.

NNNNN

MIS
Dec 2, 2002
90
0
0
GB
public Sub MailReport(stTitle As String, stAddress As String, stTrueOrFalse)

DoCmd.SendObject acSendReport, stTitle, acFormatXLS, stAddress, , , _
"Report " & Date, "Please find attached your report ._
" & vbCrLf & vbCrLf & "Regards" & vbCrLf & vbCrLf & "John Doe", stTrueOrFalse

End sub

Private Sub Command1_Click()

Call MailReport("one", "me@home.com", 0)
Call MailReport("two", "me@work.com", 0)
Call MailReport("three", "you@home.com", 0)
Call MailReport("four", "you@work.com", 0)

end sub

I use the above 2 examples subs to send reports by mail
which is fine and works well BUT:
I now want to do a simular thing however I want to
mail the reports to several recipients therefore
it would be far better to have a table of email addresses
I don't know how to do this (the dreaded dlookup perhaps)?
I think the table would consist of
reportName mailAddress
one me@home.com etc

Any ideas please

Thanks
 
Try this:
(Access 2000 +)

Private Sub Command1_Click()
Dim rst As Recordset
Dim strSQL As String
Dim strRecipients As String

strSQL = "Select * from tblEmailAddress where ReportName ='ONE'"
rst.Open strSQL, CurrentProject.Connection, adOpenStatic, adLockOptimistic
Do While Not rst.EOF
strRecipients = rst!EmailAddress & ";"
rst.MoveNext
Loop
rst.Close
'-Strip off the final semicolon
strRecipients = Left(strRecipients, Len(strRecipients) - 1)
Call MailReport("one", strRecipients, 0)

'-- Do it again for each report, or build a recordset of unique
'-- report names from the email table, then loop through and
'-- retrieve email addresses for each unique report.

End Sub
 
I am just getting started with trying to automate my reports and sending them. Exactly what you have done. Is it possible for you to display or send me all your coding for this event. THanks

It would really help a lot.

I am basically trying to save a report as a PDF them send that PDF as an attachment on the first of every month.

I do not now where to start, any help is appreciated.

 
I would be glad to help you
whats your email address I will send you a
sample

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top