Arvin:
Thank you for the code, but what do I do with it? Where do I input it?
Abigail
----- Arvin Meyer wrote: -----
Abigail said:
I have accumulated 143 e-mail addresses in an Access 2000
database. Now I want to send an e-mail message to those
addresses. How can I get the addresses from Access to the
BCC line of an e-mail form?
Abigail, this code is free unless you use it to spam. If used for unsolicted
commercial email, you must pay me $100 per each email sent!
Function EmailBrokers(strTo As String, strSubject _
As String, Optional varMsg As Variant, Optional varPath As String =
"")
' © Arvin Meyer 1997 - 2003 Free unless used for spam.
' Copyright notice to be left in tact
'Set reference to Outlook
On Error GoTo Errhandler
Dim strBCC As String
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim rst As DAO.Recordset
Dim objOutl As Outlook.Application
Dim objEml As Outlook.MailItem
Dim i As Integer
Dim strSource As String
Set db = CurrentDb
Set rst = qdf.OpenRecordset("YourQryName")
Set objOutl = CreateObject("Outlook.application")
Set objEml = objOutl.createItem(olMailitem)
With rst
If .RecordCount > 0 Then
.MoveLast
.MoveFirst
End If
End With
For i = 1 To rst.RecordCount
If Len(rst!EmailAddress) > 0 Then
strBCC = strBCC & rst!EmailAddress & ";"
End If
rst.MoveNext
Next i
strBCC = Left$(strBCC, Len(strBCC) - 1)
'Debug.Print strBCC
With objEml
.To = strTo
.BCC = strBCC
.Subject = strSubject
If Not IsNull(varMsg) Then
.Body = varMsg
End If
If Len(varPath & vbNullString) > 0 Then
.Attachments.Add varPath
End If
.Display
' .Send ' uncomment to send automatically.
End With
ExitHere:
Set objOutl = Nothing
Set objEml = Nothing
Set rst = Nothing
Set db = Nothing
Exit Function
Errhandler:
MsgBox Err.Number & ": " & Err.Description
Resume ExitHere
End Function
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access