Sending email to multiple recipients

  • Thread starter Thread starter GD
  • Start date Start date
G

GD

HELP!!!

I've seen several useful threads on this site, but my code following skills
are limited at this point. Can someone walk me through this?

I have a query (qryEmailMult) that includes an EmailAddress field. How
would I open a new Outlook mail message screen, and export all records in the
EmailAddress field to the To... box of the mail message?

Is this possible? Or are there alternatives? THANKS!!
 
Thanks for the response, S.Clark. A purchased solution would be nice, but my
company is not in the purchasing mood right now (more like a downsizing
mood!).

I may have understated my code skills a bit. I've used VBA before at a
simpler level, so if someone can give me an example of the code I need (+ the
other steps in the procedure), and specify the spots I need to customize with
my information, I should be good to go.
 
Below is a simple example of using the SendObject command, fired by the
OnClick event of a form control called "Email":

==============================

Private Sub email_Click()
If IsNull() Then
MsgBox " No address found ! ", vbExclamation, "Missing e-mail"
Else
On Error Resume Next
DoCmd.SendObject , , , Me![Email], , , "From [your name here]"
End If

If Err.Number = 2501 Then
MsgBox " Email message cancelled ", vbExclamation
End If

Exit_Email_Click:
Exit Sub

Err_Email_Click:
MsgBox Error$
Resume Exit_Email_Click

End Sub

====================================

Here's an example of using a form with a multi-select list box (called
"lstMailTo") and a command button (called "cmdEmail"): Apologies to the
original author whose info I've lost. You'll also need form controls for
the subject line and message text, and you'll need to create the query data
source for the listbox.

==================================
Private Sub cmdEmail_Click()
On Error GoTo Err_cmdEmail_Click

Dim strEmail As String
Dim strMailSubject As String
Dim strMsg As String

strEmail = Me.txtSelected & vbNullString
strMailSubject = Me.txtMailSubject & vbNullString
strMsg = Me.txtMsg & vbNullString & vbCrLf & vbCrLf & "[your signature
here]"

DoCmd.SendObject , , , To:=strEmail, Bcc:=strEmail,
subject:=strMailSubject, MessageText:=strMsg

Err_cmdEmail_Click:
If Err.Number = 2501 Then
MsgBox " Email message cancelled ", vbExclamation
Else
' MsgBox Err.Description
Resume Exit_cmdEmail_Click
End If

Exit_cmdEmail_Click:
Exit Sub

End Sub

Private Sub Form_Open(Cancel As Integer)
Me!lstMailTo.RowSource = "[My Query]"
Me!txtMsg.SetFocus
End Sub

Private Sub lstMailTo_Click()
Dim varItem As Variant
Dim strList As String

Me.cmdEmail.Enabled = True

With Me!lstMailTo
If .MultiSelect = 0 Then
Me!txtSelected = .Value
Else
For Each varItem In .ItemsSelected
strList = strList & .Column(0, varItem) & ";"
Next varItem
strList = Left$(strList, Len(strList) - 1)
Me!txtSelected = strList
Me!txtTotalSelected.Requery
End If
End With
End Sub

====================================
I typically add unbound controls with expressions to show the # of total
records in the listbox
(=IIf([lstMailto].[ListCount]>0,[lstMailto].[ListCount]-1,0)) and the # of
records selected (=[lstMailto].[itemsSelected].[Count])

Good luck
-Ed
 
Back
Top