Jay
You can open a recordset and loop through it to mail one at a time.
Here is some sample code:
Function SendEmail()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
On Error GoTo SendEmail_Err
Set db = CurrentDb
strSQL = "SELECT Email From MyTable " _
& "WHERE CustomerType = '" & Me.CustomerType & "'"
Set rs = db.OpenRecordset(strSQL, dbOpenSnapshot)
rs.MoveLast
rs.MoveFirst
If rs.EOF Or rs.BOF Then
MsgBox "No recipients found for " & Me.CustomerType
Exit Function
End If
Do While Not rs.EOF
DoCmd.SendObject acReport, objectName:="Customers", _
Ouptutformat:=acFormatPDF, To:=rs.Email, _
Subject:="subjectGoesHere", _
Message:="messageGoesHere", EditMessage:=False
rs.MoveNext
Loop
SendEmail_Exit:
Set rs = Nothing
Set db = Nothing
Exit Function
SendEmail_Err:
MsgBox Error$
Resume SendEmail_Exit
End Function
Function SendEmail()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
On Error GoTo SendEmail_Err
Set db = CurrentDb
strSQL = "SELECT Email From MyTable " _
& "WHERE CustomerType = '" & Me.CustomerType & "'"
Set rs = db.OpenRecordset(strSQL, dbOpenSnapshot)
rs.MoveLast
rs.MoveFirst
If rs.EOF Or rs.BOF Then
MsgBox "No recipients found for " & Me.CustomerType
Exit Function
End If
Do While Not rs.EOF
DoCmd.SendObject acReport, objectName:="Customers", _
Ouptutformat:=acFormatPDF, To:=rs.Email, _
Subject:="subjectGoesHere", _
Message:="messageGoesHere", EditMessage:=False
rs.MoveNext
Loop
SendEmail_Exit:
Set rs = Nothing
Set db = Nothing
Exit Function
SendEmail_Err:
MsgBox Error$
Resume SendEmail_Exit
End Function
Regards,
Bill Mosca, Founder - MS_Access_Professionals
http://www.thatlldoit.com
Microsoft Office Access MVP
https://mvp.support.microsoft.com/profile=C4D9F5E7-BB03-4291-B816-64270730881E
My nothing-to-do-with-Access blog
http://wrmosca.wordpress.com
--- In MS_Access_Professionals@yahoogroups.com, "Jay Beckham" <jay@...> wrote:
>
> I know that under forms you can create a button with the MailReport option
> which calls the EmailDatabaseObject. And if you behind that object you can
> enter an email address.
>
>
>
> Here is what I need to do.
>
> Run a query to select clients with email addresses or select certain email
> addresses based on another field e.g. customer type.
>
>
>
> Then I want to email a document or Pdf or some other file to all of the
> email addresses selected by the query. AND I want each one to go out one at
> a time in the To: rather than Bcc: Emailing using Bcc looks like spam to
> come email servers.
>
>
>
> Any ideas?
>
>
>
> Thanks
>
>
>
> Jay Beckham
>
>
>
>
>
>
>
> [Non-text portions of this message have been removed]
>
| Reply via web post | Reply to sender | Reply to group | Start a New Topic | Messages in this topic (2) |
Tidak ada komentar:
Posting Komentar