I have a form that does something similar to what you want. I have a form that has a command button. In the on-click event it will bring up another form that allows you to select multiple recipients, then send. It doesn't include attachments. I have pasted the code. If you need anything else, let me know. Hope this helps.
Dim rs As Recordset, strSQL As String, strUpdate As String
Dim lngKeyID As Long, lngRecipID As Long, strRecipName As String
Dim strTo As String, strCC As String, strSubject As String, strMessage As String
Private Sub cmdMail_Click()
On Error GoTo CancelMail
' Check for recipients
strSQL = "SELECT * FROM qryEmailMemo WHERE EmailMemo_MemoIDKey = " & LngMemoKey
Set rs = CurrentDb.OpenRecordset(strSQL)
If rs.EOF Then MsgBox "There are no recipients selected": Exit Sub
' Set Mail "To"
strSQL = "SELECT * FROM qryEmailMemo WHERE EmailMemo_RecipType = 1 AND EmailMemo_MemoIDKey = " & LngMemoKey
Set rs = CurrentDb.OpenRecordset(strSQL, dbOpenDynaset)
If rs.EOF Then strTo = "": GoTo MailCC
rs.MoveFirst
'strTo = "<" & rs!RecipName & ">" & rs!RecipEmail
strTo = rs!RecipEmail
rs.MoveNext
Do While Not rs.EOF
'strTo = strTo & ";" & "<" & rs!RecipName & ">" & rs!RecipEmail
strTo = strTo & ";" & rs!RecipEmail
rs.MoveNext
Loop
'Set Mail "CC"
MailCC:
strSQL = "SELECT * FROM qryEmailMemo WHERE EmailMemo_RecipType = 2 AND EmailMemo_MemoIDKey = " & LngMemoKey
Set rs = CurrentDb.OpenRecordset(strSQL, dbOpenDynaset)
If rs.EOF Then strCC = "": GoTo CreateMessage
rs.MoveFirst
'strCC = "<" & rs!RecipName & ">" & rs!RecipEmail
strCC = rs!RecipEmail
rs.MoveNext
Do While Not rs.EOF
'strCC = strCC & ";" & "<" & rs!RecipName & ">" & rs!RecipEmail
strCC = strCC & ";" & rs!RecipEmail
rs.MoveNext
Loop
' Set Subject & Text, Create Message
CreateMessage:
strSubject = "RE: " & Me.txtCustomer
If IsNull(Me.txtMemo) Or Me.txtMemo = "" Then
strMessage = ""
Else
strMessage = Me.txtMemo
End If
DoCmd.SendObject , , , strTo, strCC, , strSubject, strMessage
' Update tblEmailMemo after sending message
strUpdate = _
"UPDATE tblEmailMemo " & vbCrLf & _
"SET EmailMemo_RecipSent = -1, EmailMemo_RecipListed = 0, EmailMemo_EmailTime = Now()" & vbCrLf & _
"WHERE EmailMemo_MemoIDKey = " & LngMemoKey & vbCrLf & _
"AND EmailMemo_RecipListed = -1"
CurrentDb.Execute (strUpdate)
DoCmd.Close
Exit Sub
' If message cancels before sending
CancelMail:
MsgBox "Mail message was cancelled"
End Sub
Private Sub cboSelectRecipientTo_AfterUpdate()
strRecipName = Me.cboSelectRecipientTo.Column(1)
strSQL = "Do you want to add " & strRecipName & " as a (To) Recipient ?"
If MsgBox(strSQL, vbYesNo + vbDefaultButton1) = vbNo Then Exit Sub
lngRecipID = Me.cboSelectRecipientTo
strSQL = "tblEmailMemo"
Set rs = CurrentDb.OpenRecordset(strSQL, dbOpenDynaset)
rs.AddNew
rs!EmailMemo_MemoIDKey = LngMemoKey
rs!EmailMemo_RecipIDKey = lngRecipID
rs!EmailMemo_RecipType = 1
rs!EmailMemo_RecipListed = -1
rs.Update
rs.Close
strQueryCriteria = LngMemoKey
Me.lstRecipientsTo.Requery
Me.cboSelectRecipientTo = ""
Me.cboSelectRecipientTo.SetFocus
End Sub
Private Sub cmdDeleteRecipientTo_Click()
Me.lstRecipientsTo.SetFocus
If IsNull(Me.lstRecipientsTo.Column(0)) Then
strSQL = "You must first select a recipient to Delete"
MsgBox strSQL
Exit Sub
End If
lngKeyID = Me.lstRecipientsTo.Column(0)
strRecipName = Me.lstRecipientsTo.Column(2)
strSQL = "Are you sure you want to remove " & strRecipName & " from the e-mail ?"
If MsgBox(strSQL, vbYesNo + vbDefaultButton2) = vbNo Then Exit Sub
Set rs = CurrentDb.OpenRecordset("tblEmailMemo", dbOpenDynaset)
rs.FindFirst "[EmailMemo_ID] = " & lngKeyID
rs.Delete
strQueryCriteria = LngMemoKey
Me.lstRecipientsTo.Requery
Me.cboSelectRecipientTo.SetFocus
End Sub
Private Sub cboSelectRecipientCC_AfterUpdate()
strRecipName = Me.cboSelectRecipientCC.Column(1)
strSQL = "Do you want to add " & strRecipName & " as a (CC) Recipient ?"
If MsgBox(strSQL, vbYesNo + vbDefaultButton1) = vbNo Then Exit Sub
lngRecipID = Me.cboSelectRecipientCC
strSQL = "tblEmailMemo"
Set rs = CurrentDb.OpenRecordset(strSQL, dbOpenDynaset)
rs.AddNew
rs!EmailMemo_MemoIDKey = LngMemoKey
rs!EmailMemo_RecipIDKey = lngRecipID
rs!EmailMemo_RecipType = 2
rs!EmailMemo_RecipListed = -1
rs.Update
rs.Close
strQueryCriteria = LngMemoKey
Me.lstRecipientsCC.Requery
Me.cboSelectRecipientCC = ""
Me.cboSelectRecipientCC.SetFocus
End Sub
Private Sub cmdDeleteRecipientCC_Click()
Me.lstRecipientsCC.SetFocus
If IsNull(Me.lstRecipientsCC.Column(0)) Then
strSQL = "You must first select a recipient to Delete"
MsgBox strSQL
Exit Sub
End If
lngKeyID = Me.lstRecipientsCC.Column(0)
strRecipName = Me.lstRecipientsCC.Column(2)
strSQL = "Are you sure you want to remove " & strRecipName & " from the e-mail ?"
If MsgBox(strSQL, vbYesNo + vbDefaultButton2) = vbNo Then Exit Sub
Set rs = CurrentDb.OpenRecordset("tblEmailMemo", dbOpenDynaset)
rs.FindFirst "[EmailMemo_ID] = " & lngKeyID
rs.Delete
strQueryCriteria = LngMemoKey
Me.lstRecipientsCC.Requery
Me.cboSelectRecipientCC.SetFocus
End Sub
Private Sub Form_Current()
strQueryCriteria = LngMemoKey
Me.lstRecipientsTo.Requery
Me.cboSelectRecipientTo = ""
Me.lstRecipientsCC.Requery
Me.cboSelectRecipientCC = ""
Me.cboSelectRecipientTo.SetFocus
End Sub
Private Sub cmdExit_Click()
DoCmd.Close
End Sub
Thanks
![[pc3] [pc3] [pc3]](/data/assets/smilies/pc3.gif)
LeafyJellyFish