table contents as email recips

bpaquette

Registered User.
Local time
Today, 05:04
Joined
Aug 13, 2003
Messages
119
so i have a table with like 5 email addresses, and some code that docmd.sendobject's a report or sometimes a query, and i want the to box to be populated with every record in the aforementioned table.

i searched the archives but no simple answer leaped out at me -- is there one?


thanks to anyone in advance!
 
Someone posted this code up here a while ago (sorry I don't know who)

Code:
Private Sub YourButton_Click()

      Dim EmailApp, NameSpace, EmailSend As Object

      Set EmailApp = CreateObject("Outlook.Application")
      Set NameSpace = EmailApp.getNameSpace("MAPI")
      Set EmailSend = EmailApp.CreateItem(0)
      
      EmailSend.To = "email@wherever.bla"
      EmailSend.Subject = "Your Subject Here"
      EmailSend.Body = "Hello," & vbCrLf & vbCrLf & "Attached is the latest Snapshot"
      EmailSend.Attachments.Add "C:\Temp\Report1.snp"
      EmailSend.Send
      
      Set EmailApp = Nothing
      Set NameSpace = Nothing
      Set EmailSend = Nothing

End Sub

You can use a recordset to move through the table where the recipients are and add the addresses to an array. Then just pass the array to EmailSend.To and you should be away...

HTH

Tom
 

Users who are viewing this thread

Back
Top Bottom